From 3d9ed62f4aee91f5281c6ff47053d6ecafe3fd9b Mon Sep 17 00:00:00 2001 From: Nick Date: Wed, 10 May 2023 22:10:57 -0400 Subject: [PATCH] Reenable creating default webhooks. (#24626) Fixes #24624 This seems to have been broken in https://github.com/go-gitea/gitea/pull/21563 Previously, this code read ``` // Are we looking at default webhooks? if ctx.Params(":configType") == "default-hooks" { return &orgRepoCtx{ IsAdmin: true, Link: path.Join(setting.AppSubURL, "/admin/hooks"), LinkNew: path.Join(setting.AppSubURL, "/admin/default-hooks"), NewTemplate: tplAdminHookNew, }, nil } // Must be system webhooks instead return &orgRepoCtx{ IsAdmin: true, IsSystemWebhook: true, Link: path.Join(setting.AppSubURL, "/admin/hooks"), LinkNew: path.Join(setting.AppSubURL, "/admin/system-hooks"), NewTemplate: tplAdminHookNew, }, nil ``` but was simplified to ``` return &ownerRepoCtx{ IsAdmin: true, IsSystemWebhook: ctx.Params(":configType") == "system-hooks", Link: path.Join(setting.AppSubURL, "/admin/hooks"), LinkNew: path.Join(setting.AppSubURL, "/admin/system-hooks"), NewTemplate: tplAdminHookNew, }, nil ``` In other words, combining the `IsSystemWebhook` check into a one-liner and forgetting that `LinkNew` also depended on it. This meant the rendered `
` always POSTed to `/admin/system-hooks`, even when you had GETed `/admin/default-hooks/gitea/new`. --- routers/web/repo/webhook.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routers/web/repo/webhook.go b/routers/web/repo/webhook.go index a21b405c9..46b0f4910 100644 --- a/routers/web/repo/webhook.go +++ b/routers/web/repo/webhook.go @@ -99,7 +99,7 @@ func getOwnerRepoCtx(ctx *context.Context) (*ownerRepoCtx, error) { IsAdmin: true, IsSystemWebhook: ctx.Params(":configType") == "system-hooks", Link: path.Join(setting.AppSubURL, "/admin/hooks"), - LinkNew: path.Join(setting.AppSubURL, "/admin/system-hooks"), + LinkNew: path.Join(setting.AppSubURL, "/admin/", ctx.Params(":configType")), NewTemplate: tplAdminHookNew, }, nil }