Skip to content

Commit ba47d1c

Browse files
committed
Change general form binding to gogs form
1 parent 90ab305 commit ba47d1c

File tree

2 files changed

+9
-12
lines changed

2 files changed

+9
-12
lines changed

routers/repo/webhook.go

+5-8
Original file line numberDiff line numberDiff line change
@@ -198,20 +198,17 @@ func WebHooksNewPost(ctx *context.Context, form auth.NewWebhookForm) {
198198
}
199199

200200
// GogsHooksNewPost response for creating webhook
201-
func GogsHooksNewPost(ctx *context.Context, form auth.NewWebhookForm) {
202-
newGenericWebhookPost(ctx, form, models.GOGS)
201+
func GogsHooksNewPost(ctx *context.Context, form auth.NewGogshookForm) {
202+
newGogsWebhookPost(ctx, form, models.GOGS)
203203
}
204204

205-
func newGenericWebhookPost(ctx *context.Context, form auth.NewWebhookForm, kind models.HookTaskType) {
205+
// newGogsWebhookPost response for creating gogs hook
206+
func newGogsWebhookPost(ctx *context.Context, form auth.NewGogshookForm, kind models.HookTaskType) {
206207
ctx.Data["Title"] = ctx.Tr("repo.settings.add_webhook")
207208
ctx.Data["PageIsSettingsHooks"] = true
208209
ctx.Data["PageIsSettingsHooksNew"] = true
209210
ctx.Data["Webhook"] = models.Webhook{HookEvent: &models.HookEvent{}}
210-
211-
ctx.Data["HookType"] = "gitea"
212-
if kind == models.GOGS {
213-
ctx.Data["HookType"] = "gogs"
214-
}
211+
ctx.Data["HookType"] = "gogs"
215212

216213
orCtx, err := getOrgRepoCtx(ctx)
217214
if err != nil {

routers/routes/routes.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -444,15 +444,15 @@ func RegisterRoutes(m *macaron.Macaron) {
444444
m.Post("/delete", admin.DeleteDefaultWebhook)
445445
m.Get("/:type/new", repo.WebhooksNew)
446446
m.Post("/gitea/new", bindIgnErr(auth.NewWebhookForm{}), repo.WebHooksNewPost)
447-
m.Post("/gogs/new", bindIgnErr(auth.NewWebhookForm{}), repo.GogsHooksNewPost)
447+
m.Post("/gogs/new", bindIgnErr(auth.NewGogshookForm{}), repo.GogsHooksNewPost)
448448
m.Post("/slack/new", bindIgnErr(auth.NewSlackHookForm{}), repo.SlackHooksNewPost)
449449
m.Post("/discord/new", bindIgnErr(auth.NewDiscordHookForm{}), repo.DiscordHooksNewPost)
450450
m.Post("/dingtalk/new", bindIgnErr(auth.NewDingtalkHookForm{}), repo.DingtalkHooksNewPost)
451451
m.Post("/telegram/new", bindIgnErr(auth.NewTelegramHookForm{}), repo.TelegramHooksNewPost)
452452
m.Post("/msteams/new", bindIgnErr(auth.NewMSTeamsHookForm{}), repo.MSTeamsHooksNewPost)
453453
m.Get("/:id", repo.WebHooksEdit)
454454
m.Post("/gitea/:id", bindIgnErr(auth.NewWebhookForm{}), repo.WebHooksEditPost)
455-
m.Post("/gogs/:id", bindIgnErr(auth.NewWebhookForm{}), repo.GogsHooksEditPost)
455+
m.Post("/gogs/:id", bindIgnErr(auth.NewGogshookForm{}), repo.GogsHooksEditPost)
456456
m.Post("/slack/:id", bindIgnErr(auth.NewSlackHookForm{}), repo.SlackHooksEditPost)
457457
m.Post("/discord/:id", bindIgnErr(auth.NewDiscordHookForm{}), repo.DiscordHooksEditPost)
458458
m.Post("/dingtalk/:id", bindIgnErr(auth.NewDingtalkHookForm{}), repo.DingtalkHooksEditPost)
@@ -585,7 +585,7 @@ func RegisterRoutes(m *macaron.Macaron) {
585585
m.Post("/delete", org.DeleteWebhook)
586586
m.Get("/:type/new", repo.WebhooksNew)
587587
m.Post("/gitea/new", bindIgnErr(auth.NewWebhookForm{}), repo.WebHooksNewPost)
588-
m.Post("/gogs/new", bindIgnErr(auth.NewWebhookForm{}), repo.GogsHooksNewPost)
588+
m.Post("/gogs/new", bindIgnErr(auth.NewGogshookForm{}), repo.GogsHooksNewPost)
589589
m.Post("/slack/new", bindIgnErr(auth.NewSlackHookForm{}), repo.SlackHooksNewPost)
590590
m.Post("/discord/new", bindIgnErr(auth.NewDiscordHookForm{}), repo.DiscordHooksNewPost)
591591
m.Post("/dingtalk/new", bindIgnErr(auth.NewDingtalkHookForm{}), repo.DingtalkHooksNewPost)
@@ -647,7 +647,7 @@ func RegisterRoutes(m *macaron.Macaron) {
647647
m.Post("/delete", repo.DeleteWebhook)
648648
m.Get("/:type/new", repo.WebhooksNew)
649649
m.Post("/gitea/new", bindIgnErr(auth.NewWebhookForm{}), repo.WebHooksNewPost)
650-
m.Post("/gogs/new", bindIgnErr(auth.NewWebhookForm{}), repo.GogsHooksNewPost)
650+
m.Post("/gogs/new", bindIgnErr(auth.NewGogshookForm{}), repo.GogsHooksNewPost)
651651
m.Post("/slack/new", bindIgnErr(auth.NewSlackHookForm{}), repo.SlackHooksNewPost)
652652
m.Post("/discord/new", bindIgnErr(auth.NewDiscordHookForm{}), repo.DiscordHooksNewPost)
653653
m.Post("/dingtalk/new", bindIgnErr(auth.NewDingtalkHookForm{}), repo.DingtalkHooksNewPost)

0 commit comments

Comments
 (0)