summaryrefslogtreecommitdiffstats
path: root/routers/web
diff options
context:
space:
mode:
authorEarl Warren <earl-warren@noreply.codeberg.org>2024-03-27 14:45:04 +0100
committerEarl Warren <earl-warren@noreply.codeberg.org>2024-03-27 14:45:04 +0100
commite41e18f87e62bb4478f92305c85727ae2c859f27 (patch)
tree07ba5838442ba00815b1754c4f9bbeb6fbc857b3 /routers/web
parentMerge pull request 'Improve localization of repo summary' (#2756) from 0ko/fo... (diff)
parent[REFACTOR] webhook.Handler interface (diff)
downloadforgejo-e41e18f87e62bb4478f92305c85727ae2c859f27.tar.xz
forgejo-e41e18f87e62bb4478f92305c85727ae2c859f27.zip
Merge pull request '[REFACTOR] webhook.Handler interface' (#2758) from oliverpool/forgejo:webhook_2_interface into forgejo
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/2758 Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org>
Diffstat (limited to 'routers/web')
-rw-r--r--routers/web/repo/setting/webhook.go14
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)