aboutsummaryrefslogtreecommitdiffstats
path: root/services/webhook
Commit message (Collapse)AuthorAgeFilesLines
* Refactor functions to reduce repopath expose (#33892)Lunny Xiao11 days1-3/+3
|
* Add workflow_job webhook (#33694)ChristopherHX2025-03-1112-0/+208
| | | | | | | | | Provide external Integration information about the Queue lossly based on https://docs.github.com/en/webhooks/webhook-events-and-payloads?actionType=completed#workflow_job Naming conflicts between GitHub & Gitea are here, Blocked => Waiting, Waiting => Queued Rationale Enhancement for ephemeral runners management #33570
* Adjust appearence of commit status webhook (#33778)Denys Konovalov2025-03-032-5/+12
| | | | | | | | | | | | | | | | Some visual improvement for the commit status webhook message introduced by #33320 - use short commit SHA as already done in e. g. commit webhook - fix spacing, link text - do not set user link for internal gitea-actions user Before: ![grafik](https://github.com/user-attachments/assets/9c460846-c350-444c-89b5-8a0d5e26cb86) After: ![grafik](https://github.com/user-attachments/assets/05519cd8-6d8f-432b-bd9d-082de558a55a)
* Webhook add X-Gitea-Hook-Installation-Target-Type Header (#33752)ChristopherHX2025-03-013-4/+23
| | | | | | | | | | | | This is a X-GitHub Header port * repository for repository webhooks (matches GitHub) * organization for organization webhooks (matches GitHub) * user for user webhooks (Gitea specific) * system for system webhooks (Gitea specific) * default for default hooks needs testing (Gitea specific) - `X-Gitea-Hook-Installation-Target-Type` - `X-GitHub-Hook-Installation-Target-Type`
* Use test context in tests and new loop system in benchmarks (#33648)TheFox0x72025-02-209-22/+13
| | | | | | | | Replace all contexts in tests with go1.24 t.Context() --------- Co-authored-by: Giteabot <teabot@gitea.io> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Make actions URL in commit status webhooks absolute (#33620)Lunny Xiao2025-02-181-1/+7
| | | | | | | | | | Gitea Actions generated target url doesn't contain host and port. So we need to include them for external webhook visiting. Fix #33603 --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Fix commit status events (#33320)Lunny Xiao2025-02-0411-0/+76
| | | | | | | | | | Fix #32873 Fix #33201 ~Fix #33244~ ~Fix #33302~ depends on ~#33396~ A part of this PR should be backported to v1.23 manually.
* Add tests for webhook and fix some webhook bugs (#33396)Lunny Xiao2025-01-3012-15/+54
| | | | | | This PR created a mock webhook server in the tests and added integration tests for generic webhooks. It also fixes bugs in package webhooks and pull request comment webhooks.
* Refactor webhook events (#33337)Lunny Xiao2025-01-231-8/+2
| | | | | | | Extract from #33320 This PR uses a map instead of a struct to store webhook event information. It removes many duplicated functions and makes the logic clearer.
* Refactor RefName (#33234)wxiaoguang2025-01-132-11/+7
| | | And fix some FIXMEs
* Test webhook email (#33033)wxiaoguang2024-12-301-0/+12
| | | Close #27918
* Add more load functions to make sure the reference object loaded (#32901)Lunny Xiao2024-12-191-0/+4
| | | Fix #32897
* Enable tenv and testifylint rules (#32852)TheFox0x72024-12-152-17/+17
| | | | Enables tenv and testifylint linters closes: https://github.com/go-gitea/gitea/issues/32842
* Only provide the commit summary for Discord webhook push events (#32432)Kemal Zebari2024-11-073-3/+17
| | | | | | | | | | | | Resolves #32371. #31970 should have just showed the commit summary, but `strings.SplitN()` was misused such that we did not perform any splitting at all and just used the message. This was not caught in the unit test made in that PR since the test commit summary was > 50 (which truncated away the commit description). This snapshot resolves this and adds another unit test to ensure that we only show the commit summary.
* Add new event commit status creation and webhook implementation (#27151)Lunny Xiao2024-11-071-0/+31
| | | | | | | | | | | This PR introduces a new event which is similar as Github's. When a new commit status submitted, the event will be trigged. That means, now we can receive all feedback from CI/CD system in webhooks or other notify systems. ref: https://docs.github.com/en/webhooks/webhook-events-and-payloads#status Fix #20749
* Support requested_reviewers data in comment webhook events (#26178)谈笑风生间2024-10-161-32/+42
| | | | | | | | | | | close #25833 Currently, the information for "requested_reviewers" is only included in the webhook event for reviews. I would like to suggest adding this information to the webhook event for "PullRequest comment" as well, as they both pertain to the "PullRequest" event. Also, The reviewer information for the Pull Request is not displayed when it is approved or rejected.
* Truncate commit message during Discord webhook push events (#31970)Kemal Zebari2024-09-243-3/+32
| | | Resolves #31668.
* Support allowed hosts for migrations to work with proxy (#32025)Jason Song2024-09-111-1/+1
|
* Refactor webhook (#31587)wxiaoguang2024-07-1014-177/+161
| | | | | | A more complete fix for #31588 1. Make "generic" code more readable 2. Clarify HTML or Markdown for the payload content
* Enable `unparam` linter (#31277)silverwind2024-06-119-9/+9
| | | | | | | | | | | | Enable [unparam](https://github.com/mvdan/unparam) linter. Often I could not tell the intention why param is unused, so I put `//nolint` for those cases like webhook request creation functions never using `ctx`. --------- Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: delvh <dev.lh@web.de>
* Enable more `revive` linter rules (#30608)silverwind2024-04-222-3/+0
| | | | | | | | | | | Noteable additions: - `redefines-builtin-id` forbid variable names that shadow go builtins - `empty-lines` remove unnecessary empty lines that `gofumpt` does not remove for some reason - `superfluous-else` eliminate more superfluous `else` branches Rules are also sorted alphabetically and I cleaned up various parts of `.golangci.yml`.
* Fix missed doer (#30231)Lunny Xiao2024-04-081-11/+11
| | | | | Fix #29879 Co-authored-by: Giteabot <teabot@gitea.io>
* Fix possible data race on tests (#30093)Lunny Xiao2024-03-261-1/+0
|
* Upgrade Go 1.22 and upgrade dependency (#29869)wxiaoguang2024-03-171-1/+0
|
* fix telegram webhook (#29864)Denys Konovalov2024-03-172-1/+12
| | | | | | | | | | | Fix #29837 which is a regression caused by https://github.com/go-gitea/gitea/pull/29145/files#diff-731445ee00f0f1bf2ff731f4f96ddcf51cdc53fd2faaf406eb3536fc292ea748L48. The line was probably removed by accident. --------- Co-authored-by: Giteabot <teabot@gitea.io>
* Add test for webhook (#29755)wxiaoguang2024-03-141-49/+29
| | | Follow #29690
* Fix broken webhooks (#29690)Lunny Xiao2024-03-101-1/+6
| | | Fix #29689
* Store webhook event in database (#29145)oliverpool2024-03-0722-1503/+1613
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Refactor the webhook logic, to have the type-dependent processing happen only in one place. --- ## Current webhook flow 1. An event happens 2. It is pre-processed (depending on the webhook type) and its body is added to a task queue 3. When the task is processed, some more logic (depending on the webhook type as well) is applied to make an HTTP request This means that webhook-type dependant logic is needed in step 2 and 3. This is cumbersome and brittle to maintain. Updated webhook flow with this PR: 1. An event happens 2. It is stored as-is and added to a task queue 3. When the task is processed, the event is processed (depending on the webhook type) to make an HTTP request So the only webhook-type dependent logic happens in one place (step 3) which should be much more robust. ## Consequences of the refactor - the raw event must be stored in the hooktask (until now, the pre-processed body was stored) - to ensure that previous hooktasks are correctly sent, a `payload_version` is added (version 1: the body has already been pre-process / version 2: the body is the raw event) So future webhook additions will only have to deal with creating an http.Request based on the raw event (no need to adjust the code in multiple places, like currently). Moreover since this processing happens when fetching from the task queue, it ensures that the queuing of new events (upon a `git push` for instance) does not get slowed down by a slow webhook. As a concrete example, the PR #19307 for custom webhooks, should be substantially smaller: - no need to change `services/webhook/deliver.go` - minimal change in `services/webhook/webhook.go` (add the new webhook to the map) - no need to change all the individual webhook files (since with this refactor the `*webhook_model.Webhook` is provided as argument)
* remove util.OptionalBool and related functions (#29513)65432024-03-021-3/+4
| | | | | | and migrate affected code _last refactoring bits to replace **util.OptionalBool** with **optional.Option[bool]**_
* Use `crypto/sha256` (#29386)KN4CK3R2024-02-251-1/+1
| | | | | | | | Go 1.21 improved the performance of `crypto/sha256`. It's now similar to `minio/sha256-simd`, so we should just use the standard libs. https://go.dev/doc/go1.21#crypto/sha256 https://go-review.googlesource.com/c/go/+/408795 https://github.com/multiformats/go-multihash/pull/173
* Abstract hash function usage (#28138)Adam Majer2023-12-131-0/+1
| | | | | | Refactor Hash interfaces and centralize hash function. This will allow easier introduction of different hash function later on. This forms the "no-op" part of the SHA256 enablement patch.
* Use db.Find instead of writing methods for every object (#28084)Lunny Xiao2023-11-241-2/+3
| | | | For those simple objects, it's unnecessary to write the find and count methods again and again.
* Fix Matrix and MSTeams nil dereference (#28089)KN4CK3R2023-11-1711-6/+155
| | | | | | | | | | Fixes #28088 Fixes #28094 Added missing tests. --------- Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
* Fix package webhook (#27839)Lunny Xiao2023-10-3111-1/+91
| | | | | | | Fix #23742 --------- Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
* Support allowed hosts for webhook to work with proxy (#27655)Jason Song2023-10-182-18/+58
| | | | | | | | | | | | | | | | | When `webhook.PROXY_URL` has been set, the old code will check if the proxy host is in `ALLOWED_HOST_LIST` or reject requests through the proxy. It requires users to add the proxy host to `ALLOWED_HOST_LIST`. However, it actually allows all requests to any port on the host, when the proxy host is probably an internal address. But things may be even worse. `ALLOWED_HOST_LIST` doesn't really work when requests are sent to the allowed proxy, and the proxy could forward them to any hosts. This PR fixes it by: - If the proxy has been set, always allow connectioins to the host and port. - Check `ALLOWED_HOST_LIST` before forwarding.
* Final round of `db.DefaultContext` refactor (#27587)JakobDev2023-10-141-3/+3
| | | Last part of #27065
* make writing main test easier (#27270)Lunny Xiao2023-09-281-2/+0
| | | | | | | | | This PR removed `unittest.MainTest` the second parameter `TestOptions.GiteaRoot`. Now it detects the root directory by current working directory. --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Fix release URL in webhooks (#27182)John Olheiser2023-09-219-9/+9
|
* move repository deletion to service layer (#26948)Lunny Xiao2023-09-081-0/+1
| | | Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Move notification interface to services layer (#26915)Lunny Xiao2023-09-051-47/+46
| | | Extract from #22266
* Modify the content format of the Feishu webhook (#25106)谈笑风生间2023-08-244-15/+111
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | close https://github.com/go-gitea/gitea/issues/24368 ## what my pull request does Since the official documentation states that custom bots do not support hyperlink functionality, simply adding it without making some formatting changes would result in an unappealing output. Therefore, I have modified the formatting of the output. Currently, it is only used for Feishu. --- [docs](https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/im-v1/message/create_json#%E8%B6%85%E9%93%BE%E6%8E%A5%E4%BD%BF%E7%94%A8%E8%AF%B4%E6%98%8E) <img width="641" alt="image" src="https://github.com/go-gitea/gitea/assets/75628309/360e1c81-ab64-4ef6-851e-aa450d6e85a4"> - Issue <img width="423" alt="image" src="https://github.com/go-gitea/gitea/assets/75628309/519f6fae-81ab-4ec8-89b8-f6a73ff93783"> - Issue Comment <img width="548" alt="image" src="https://github.com/go-gitea/gitea/assets/75628309/749c0d1c-3657-431e-b787-8bf4c23cce83"> - Assign <img width="431" alt="image" src="https://github.com/go-gitea/gitea/assets/75628309/066f99e5-eabb-455d-91fb-a8359cc26dc7"> <img width="457" alt="image" src="https://github.com/go-gitea/gitea/assets/75628309/c6c10f99-db83-46ef-a775-4c91979fa68f"> - Merge <img width="408" alt="image" src="https://github.com/go-gitea/gitea/assets/75628309/e627bf43-5954-45aa-acf6-261ee046802f"> - PullRequest <img width="425" alt="image" src="https://github.com/go-gitea/gitea/assets/75628309/72cfa714-d3fa-4fb9-abdd-e8508d756056">
* Add `branch_filter` to hooks API endpoints (#26599)Yarden Shoham2023-08-211-0/+1
| | | | | | | | | | | | | | | | | | We now include the branch filler in the response. - Closes #26591 # Before ![image](https://github.com/go-gitea/gitea/assets/20454870/73933940-c1a7-4573-abae-f340b63028b2) # After ![image](https://github.com/go-gitea/gitea/assets/20454870/3b3c4a85-0f7c-48c7-8617-def7a66c671d) --------- Signed-off-by: Yarden Shoham <git@yardenshoham.com> Co-authored-by: Giteabot <teabot@gitea.io>
* Add ThreadID parameter for Telegram webhooks (#25996)Earl Warren2023-08-131-0/+1
| | | | | | Telegram has recently implemented threads (channels) for group chats. Co-authored-by: neveraskedtoexist <matikot415@gmail.com>
* Add pull request review request webhook event (#26401)Yarden Shoham2023-08-091-0/+4
| | | | | | | | | | | | | | | | | | | | Add webhook events for pull request review requests - Fixes #26371 - Added support for the "Pull request review requested" and "Pull request review request removed" webhook events. - Updated the `getPullRequestPayloadInfo` function in `general.go` to handle these new webhook events. # Before ![image](https://github.com/go-gitea/gitea/assets/20454870/bd942971-fb1d-40f3-8961-46638e3588fa) # After ![image](https://github.com/go-gitea/gitea/assets/20454870/216e9c7d-0a4d-49f9-8492-2d14c88bbf4e) Signed-off-by: Yarden Shoham <git@yardenshoham.com> Co-authored-by: Giteabot <teabot@gitea.io>
* Warn instead of reporting an error when a webhook cannot be found (#26039)puni98692023-07-281-1/+6
| | | | | | | | | Attemp fix: #25744 Fixing the log level when we delete any repo then we get error hook not found by id. That should be warn level to reduce the noise in the logs. --------- Co-authored-by: delvh <dev.lh@web.de>
* For API attachments, use API URL (#25639)Lunny Xiao2023-07-101-4/+4
| | | | | | | Fix #25257 --------- Co-authored-by: Giteabot <teabot@gitea.io>
* Fix `Permission` in API returned repository struct (#25388)Jason Song2023-06-221-60/+59
| | | | | | | | | | | | | | | | | | | | | | | The old code generates `structs.Repository.Permissions` with only `access.Permission.AccessMode`, however, it should check the units too, or the value could be incorrect. For example, `structs.Repository.Permissions.Push` could be false even the doer has write access to code unit. Should fix https://github.com/renovatebot/renovate/issues/14059#issuecomment-1047961128 (Not reported by it, I just found it when I was looking into this bug) --- Review tips: The major changes are - `modules/structs/repo.go` https://github.com/go-gitea/gitea/pull/25388/files#diff-870406f6857117f8b03611c43fca0ab9ed6d6e76a2d0069a7c1f17e8fa9092f7 - `services/convert/repository.go` https://github.com/go-gitea/gitea/pull/25388/files#diff-7736f6d2ae894c9edb7729a80ab89aa183b888a26a811a0c1fdebd18726a7101 And other changes are passive.
* Fix compatible for webhook ref type (#25195)Lunny Xiao2023-06-131-3/+3
| | | | Fix #25185 Caused by #24634
* Rename NotifyPullReviewRequest to NotifyPullRequestReviewRequest (#24988)谈笑风生间2023-05-311-2/+2
| | | | | | | | | | | | after #24481 To keep consistent, maybe pull_request_review_request is better. ## what my pull request does Rename NotifyPullReviewRequest to NotifyPullRequestReviewRequest. <img width="1087" alt="image" src="https://github.com/go-gitea/gitea/assets/75628309/2cf91f02-74f2-42fe-a998-0a039b821d8d">
* Improve queue and logger context (#24924)wxiaoguang2023-05-261-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | Before there was a "graceful function": RunWithShutdownFns, it's mainly for some modules which doesn't support context. The old queue system doesn't work well with context, so the old queues need it. After the queue refactoring, the new queue works with context well, so, use Golang context as much as possible, the `RunWithShutdownFns` could be removed (replaced by RunWithCancel for context cancel mechanism), the related code could be simplified. This PR also fixes some legacy queue-init problems, eg: * typo : archiver: "unable to create codes indexer queue" => "unable to create repo-archive queue" * no nil check for failed queues, which causes unfriendly panic After this PR, many goroutines could have better display name: ![image](https://github.com/go-gitea/gitea/assets/2114189/701b2a9b-8065-4137-aeaa-0bda2b34604a) ![image](https://github.com/go-gitea/gitea/assets/2114189/f1d5f50f-0534-40f0-b0be-f2c9daa5fe92)