From e94f37f95e286ba3b982700744e7f55fdb31f046 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Thu, 23 Jan 2025 10:53:06 -0800 Subject: 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. --- services/webhook/webhook.go | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'services/webhook') 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.). -- cgit v1.2.3