From 3f044b07e8cdf4bc61768f54c7214d684bf6570e Mon Sep 17 00:00:00 2001 From: Nick Guenther Date: Tue, 9 May 2023 22:27:07 -0400 Subject: [PATCH 1/2] Reenable creating default webhooks. Fixes https://github.com/go-gitea/gitea/issues/24624 This seems to have been broken in https://github.com/go-gitea/gitea/pull/21563 Previously, the 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 ``` combining the IsSystemWebhook check into a one-liner, but forgtting the same for LinkNew. --- 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 a21b405c9676e..c70d867d1c8b0 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: "/admin/" + ctx.Params(":configType"), NewTemplate: tplAdminHookNew, }, nil } From 7df0f8d73f91254e30cb702cf0f8484dd29b2695 Mon Sep 17 00:00:00 2001 From: Nick Guenther Date: Wed, 10 May 2023 14:36:42 -0400 Subject: [PATCH 2/2] Fix bug --- 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 c70d867d1c8b0..46b0f4910819e 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: "/admin/" + ctx.Params(":configType"), + LinkNew: path.Join(setting.AppSubURL, "/admin/", ctx.Params(":configType")), NewTemplate: tplAdminHookNew, }, nil }