diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2025-01-23 10:53:06 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-01-23 18:53:06 +0000 |
commit | e94f37f95e286ba3b982700744e7f55fdb31f046 (patch) | |
tree | 72b0d58c6710e302333f089a6615a846518645d3 /services/webhook | |
parent | 594b8350b174e5832c1f91c55028ac76246bbef7 (diff) | |
download | gitea-e94f37f95e286ba3b982700744e7f55fdb31f046.tar.gz gitea-e94f37f95e286ba3b982700744e7f55fdb31f046.zip |
Refactor webhook events (#33337)
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.
Diffstat (limited to 'services/webhook')
-rw-r--r-- | services/webhook/webhook.go | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/services/webhook/webhook.go b/services/webhook/webhook.go index e0e8fa2fc1..b4609e8a51 100644 --- a/services/webhook/webhook.go +++ b/services/webhook/webhook.go @@ -137,14 +137,8 @@ func PrepareWebhook(ctx context.Context, w *webhook_model.Webhook, event webhook return nil } - for _, e := range w.EventCheckers() { - if event == e.Type { - if !e.Has() { - return nil - } - - break - } + if !w.HasEvent(event) { + return nil } // Avoid sending "0 new commits" to non-integration relevant webhooks (e.g. slack, discord, etc.). |