Skip to content

Commit aeec785

Browse files
6543techknowlogick
authored andcommitted
Change general form binding to gogs form (#8334) (#8402)
1 parent c9b8c12 commit aeec785

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
@@ -197,20 +197,17 @@ func WebHooksNewPost(ctx *context.Context, form auth.NewWebhookForm) {
197197
}
198198

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

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

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

routers/routes/routes.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -437,15 +437,15 @@ func RegisterRoutes(m *macaron.Macaron) {
437437
m.Post("/delete", admin.DeleteDefaultWebhook)
438438
m.Get("/:type/new", repo.WebhooksNew)
439439
m.Post("/gitea/new", bindIgnErr(auth.NewWebhookForm{}), repo.WebHooksNewPost)
440-
m.Post("/gogs/new", bindIgnErr(auth.NewWebhookForm{}), repo.GogsHooksNewPost)
440+
m.Post("/gogs/new", bindIgnErr(auth.NewGogshookForm{}), repo.GogsHooksNewPost)
441441
m.Post("/slack/new", bindIgnErr(auth.NewSlackHookForm{}), repo.SlackHooksNewPost)
442442
m.Post("/discord/new", bindIgnErr(auth.NewDiscordHookForm{}), repo.DiscordHooksNewPost)
443443
m.Post("/dingtalk/new", bindIgnErr(auth.NewDingtalkHookForm{}), repo.DingtalkHooksNewPost)
444444
m.Post("/telegram/new", bindIgnErr(auth.NewTelegramHookForm{}), repo.TelegramHooksNewPost)
445445
m.Post("/msteams/new", bindIgnErr(auth.NewMSTeamsHookForm{}), repo.MSTeamsHooksNewPost)
446446
m.Get("/:id", repo.WebHooksEdit)
447447
m.Post("/gitea/:id", bindIgnErr(auth.NewWebhookForm{}), repo.WebHooksEditPost)
448-
m.Post("/gogs/:id", bindIgnErr(auth.NewWebhookForm{}), repo.GogsHooksEditPost)
448+
m.Post("/gogs/:id", bindIgnErr(auth.NewGogshookForm{}), repo.GogsHooksEditPost)
449449
m.Post("/slack/:id", bindIgnErr(auth.NewSlackHookForm{}), repo.SlackHooksEditPost)
450450
m.Post("/discord/:id", bindIgnErr(auth.NewDiscordHookForm{}), repo.DiscordHooksEditPost)
451451
m.Post("/dingtalk/:id", bindIgnErr(auth.NewDingtalkHookForm{}), repo.DingtalkHooksEditPost)
@@ -578,7 +578,7 @@ func RegisterRoutes(m *macaron.Macaron) {
578578
m.Post("/delete", org.DeleteWebhook)
579579
m.Get("/:type/new", repo.WebhooksNew)
580580
m.Post("/gitea/new", bindIgnErr(auth.NewWebhookForm{}), repo.WebHooksNewPost)
581-
m.Post("/gogs/new", bindIgnErr(auth.NewWebhookForm{}), repo.GogsHooksNewPost)
581+
m.Post("/gogs/new", bindIgnErr(auth.NewGogshookForm{}), repo.GogsHooksNewPost)
582582
m.Post("/slack/new", bindIgnErr(auth.NewSlackHookForm{}), repo.SlackHooksNewPost)
583583
m.Post("/discord/new", bindIgnErr(auth.NewDiscordHookForm{}), repo.DiscordHooksNewPost)
584584
m.Post("/dingtalk/new", bindIgnErr(auth.NewDingtalkHookForm{}), repo.DingtalkHooksNewPost)
@@ -636,7 +636,7 @@ func RegisterRoutes(m *macaron.Macaron) {
636636
m.Post("/delete", repo.DeleteWebhook)
637637
m.Get("/:type/new", repo.WebhooksNew)
638638
m.Post("/gitea/new", bindIgnErr(auth.NewWebhookForm{}), repo.WebHooksNewPost)
639-
m.Post("/gogs/new", bindIgnErr(auth.NewWebhookForm{}), repo.GogsHooksNewPost)
639+
m.Post("/gogs/new", bindIgnErr(auth.NewGogshookForm{}), repo.GogsHooksNewPost)
640640
m.Post("/slack/new", bindIgnErr(auth.NewSlackHookForm{}), repo.SlackHooksNewPost)
641641
m.Post("/discord/new", bindIgnErr(auth.NewDiscordHookForm{}), repo.DiscordHooksNewPost)
642642
m.Post("/dingtalk/new", bindIgnErr(auth.NewDingtalkHookForm{}), repo.DingtalkHooksNewPost)

0 commit comments

Comments
 (0)