MCPcopy Create free account
hub / github.com/gogs/gogs / validateAndUpdateWebhook

Function validateAndUpdateWebhook

internal/route/repo/webhook.go:337–362  ·  view source on GitHub ↗
(c *context.Context, orCtx *orgRepoContext, w *database.Webhook)

Source from the content-addressed store, hash-verified

335}
336
337func validateAndUpdateWebhook(c *context.Context, orCtx *orgRepoContext, w *database.Webhook) {
338 c.Data["Webhook"] = w
339
340 if c.HasError() {
341 c.HTML(http.StatusBadRequest, orCtx.TmplNew)
342 return
343 }
344
345 field, msg, status := validateWebhook(c.Locale, w)
346 if status != http.StatusOK {
347 c.FormErr(field)
348 c.RenderWithErr(msg, status, orCtx.TmplNew, nil)
349 return
350 }
351
352 if err := w.UpdateEvent(); err != nil {
353 c.Error(err, "update event")
354 return
355 } else if err := database.UpdateWebhook(w); err != nil {
356 c.Error(err, "update webhook")
357 return
358 }
359
360 c.Flash.Success(c.Tr("repo.settings.update_hook_success"))
361 c.Redirect(fmt.Sprintf("%s/settings/hooks/%d", orCtx.Link, w.ID))
362}
363
364func WebhooksEditPost(c *context.Context, orCtx *orgRepoContext, f form.NewWebhook) {
365 c.Title("repo.settings.update_webhook")

Callers 4

WebhooksEditPostFunction · 0.85
WebhooksSlackEditPostFunction · 0.85
WebhooksDiscordEditPostFunction · 0.85
WebhooksDingtalkEditPostFunction · 0.85

Calls 11

UpdateWebhookFunction · 0.92
validateWebhookFunction · 0.85
HasErrorMethod · 0.80
HTMLMethod · 0.80
FormErrMethod · 0.80
RenderWithErrMethod · 0.80
UpdateEventMethod · 0.80
SuccessMethod · 0.80
TrMethod · 0.80
RedirectMethod · 0.80
ErrorMethod · 0.45

Tested by

no test coverage detected