diff options
author | oliverpool <git@olivier.pfad.fr> | 2024-03-20 15:44:01 +0100 |
---|---|---|
committer | oliverpool <git@olivier.pfad.fr> | 2024-03-24 10:35:06 +0100 |
commit | 702152bfdee617e30589122d24b345d34bdf81b8 (patch) | |
tree | 47aa06477a48e9265758f114796e61bee8ad19e1 /routers/web | |
parent | [BUG] Use new translation key (diff) | |
download | forgejo-702152bfdee617e30589122d24b345d34bdf81b8.tar.xz forgejo-702152bfdee617e30589122d24b345d34bdf81b8.zip |
[REFACTOR] webhook.Handler interface
Diffstat (limited to 'routers/web')
-rw-r--r-- | routers/web/repo/setting/webhook.go | 14 |
1 files changed, 3 insertions, 11 deletions
diff --git a/routers/web/repo/setting/webhook.go b/routers/web/repo/setting/webhook.go index 08e45b5137..1f78681dae 100644 --- a/routers/web/repo/setting/webhook.go +++ b/routers/web/repo/setting/webhook.go @@ -637,17 +637,9 @@ func checkWebhook(ctx *context.Context) (*ownerRepoCtx, *webhook.Webhook) { } ctx.Data["HookType"] = w.Type - switch w.Type { - case webhook_module.SLACK: - ctx.Data["SlackHook"] = webhook_service.GetSlackHook(w) - case webhook_module.DISCORD: - ctx.Data["DiscordHook"] = webhook_service.GetDiscordHook(w) - case webhook_module.TELEGRAM: - ctx.Data["TelegramHook"] = webhook_service.GetTelegramHook(w) - case webhook_module.MATRIX: - ctx.Data["MatrixHook"] = webhook_service.GetMatrixHook(w) - case webhook_module.PACKAGIST: - ctx.Data["PackagistHook"] = webhook_service.GetPackagistHook(w) + + if handler := webhook_service.GetWebhookHandler(w.Type); handler != nil { + ctx.Data["HookMetadata"] = handler.Metadata(w) } ctx.Data["History"], err = w.History(ctx, 1) |