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

Function loadWebhook

internal/route/repo/webhook.go:285–322  ·  view source on GitHub ↗
(c *context.Context, orCtx *orgRepoContext)

Source from the content-addressed store, hash-verified

283}
284
285func loadWebhook(c *context.Context, orCtx *orgRepoContext) *database.Webhook {
286 c.RequireHighlightJS()
287
288 var err error
289 var w *database.Webhook
290 if orCtx.RepoID > 0 {
291 w, err = database.GetWebhookOfRepoByID(c.Repo.Repository.ID, c.ParamsInt64(":id"))
292 } else {
293 w, err = database.GetWebhookByOrgID(c.Org.Organization.ID, c.ParamsInt64(":id"))
294 }
295 if err != nil {
296 c.NotFoundOrError(err, "get webhook")
297 return nil
298 }
299 c.Data["Webhook"] = w
300
301 switch w.HookTaskType {
302 case database.SLACK:
303 c.Data["SlackMeta"] = w.SlackMeta()
304 c.Data["HookType"] = "slack"
305 case database.DISCORD:
306 c.Data["SlackMeta"] = w.SlackMeta()
307 c.Data["HookType"] = "discord"
308 case database.DINGTALK:
309 c.Data["HookType"] = "dingtalk"
310 default:
311 c.Data["HookType"] = "gogs"
312 }
313 c.Data["FormURL"] = fmt.Sprintf("%s/settings/hooks/%s/%d", orCtx.Link, c.Data["HookType"], w.ID)
314 c.Data["DeleteURL"] = fmt.Sprintf("%s/settings/hooks/delete", orCtx.Link)
315
316 c.Data["History"], err = w.History(1)
317 if err != nil {
318 c.Error(err, "get history")
319 return nil
320 }
321 return w
322}
323
324func WebhooksEdit(c *context.Context, orCtx *orgRepoContext) {
325 c.Title("repo.settings.update_webhook")

Callers 5

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

Calls 7

SlackMetaMethod · 0.95
HistoryMethod · 0.95
GetWebhookOfRepoByIDFunction · 0.92
GetWebhookByOrgIDFunction · 0.92
RequireHighlightJSMethod · 0.80
NotFoundOrErrorMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected