(c *context.Context, orCtx *orgRepoContext)
| 283 | } |
| 284 | |
| 285 | func 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 | |
| 324 | func WebhooksEdit(c *context.Context, orCtx *orgRepoContext) { |
| 325 | c.Title("repo.settings.update_webhook") |
no test coverage detected