diff options
author | Unknwon <u@gogs.io> | 2015-08-27 23:06:14 +0800 |
---|---|---|
committer | Unknwon <u@gogs.io> | 2015-08-27 23:06:14 +0800 |
commit | 23f42d92c917564435a00e8e75633b8056bd7b0d (patch) | |
tree | 6fed7f6df4c6b039e4e43eaae2fcd5788ddba3a0 /routers/repo | |
parent | fc2d0e5470fa2fea260adba30866acda1aa945cb (diff) | |
download | gitea-23f42d92c917564435a00e8e75633b8056bd7b0d.tar.gz gitea-23f42d92c917564435a00e8e75633b8056bd7b0d.zip |
add webhook recent deliveries
Diffstat (limited to 'routers/repo')
-rw-r--r-- | routers/repo/setting.go | 55 |
1 files changed, 24 insertions, 31 deletions
diff --git a/routers/repo/setting.go b/routers/repo/setting.go index e1e1a58ce7..3e94f3210a 100644 --- a/routers/repo/setting.go +++ b/routers/repo/setting.go @@ -417,15 +417,22 @@ func SlackHooksNewPost(ctx *middleware.Context, form auth.NewSlackHookForm) { ctx.Redirect(orCtx.Link + "/settings/hooks") } -func checkWebhook(ctx *middleware.Context) *models.Webhook { - w, err := models.GetWebhookById(ctx.ParamsInt64(":id")) +func checkWebhook(ctx *middleware.Context) (*OrgRepoCtx, *models.Webhook) { + orCtx, err := getOrgRepoCtx(ctx) + if err != nil { + ctx.Handle(500, "getOrgRepoCtx", err) + return nil, nil + } + ctx.Data["BaseLink"] = orCtx.Link + + w, err := models.GetWebhookByID(ctx.ParamsInt64(":id")) if err != nil { - if err == models.ErrWebhookNotExist { - ctx.Handle(404, "GetWebhookById", nil) + if models.IsErrWebhookNotExist(err) { + ctx.Handle(404, "GetWebhookByID", nil) } else { - ctx.Handle(500, "GetWebhookById", err) + ctx.Handle(500, "GetWebhookByID", err) } - return nil + return nil, nil } switch w.HookTaskType { @@ -436,7 +443,12 @@ func checkWebhook(ctx *middleware.Context) *models.Webhook { ctx.Data["HookType"] = "gogs" } w.GetEvent() - return w + + ctx.Data["History"], err = w.History(1) + if err != nil { + ctx.Handle(500, "History", err) + } + return orCtx, w } func WebHooksEdit(ctx *middleware.Context) { @@ -444,17 +456,11 @@ func WebHooksEdit(ctx *middleware.Context) { ctx.Data["PageIsSettingsHooks"] = true ctx.Data["PageIsSettingsHooksEdit"] = true - ctx.Data["Webhook"] = checkWebhook(ctx) + orCtx, w := checkWebhook(ctx) if ctx.Written() { return } - - orCtx, err := getOrgRepoCtx(ctx) - if err != nil { - ctx.Handle(500, "getOrgRepoCtx", err) - return - } - ctx.Data["BaseLink"] = orCtx.Link + ctx.Data["Webhook"] = w ctx.HTML(200, orCtx.NewTemplate) } @@ -464,19 +470,12 @@ func WebHooksEditPost(ctx *middleware.Context, form auth.NewWebhookForm) { ctx.Data["PageIsSettingsHooks"] = true ctx.Data["PageIsSettingsHooksEdit"] = true - w := checkWebhook(ctx) + orCtx, w := checkWebhook(ctx) if ctx.Written() { return } ctx.Data["Webhook"] = w - orCtx, err := getOrgRepoCtx(ctx) - if err != nil { - ctx.Handle(500, "getOrgRepoCtx", err) - return - } - ctx.Data["BaseLink"] = orCtx.Link - if ctx.HasError() { ctx.HTML(200, orCtx.NewTemplate) return @@ -511,19 +510,12 @@ func SlackHooksEditPost(ctx *middleware.Context, form auth.NewSlackHookForm) { ctx.Data["PageIsSettingsHooks"] = true ctx.Data["PageIsSettingsHooksEdit"] = true - w := checkWebhook(ctx) + orCtx, w := checkWebhook(ctx) if ctx.Written() { return } ctx.Data["Webhook"] = w - orCtx, err := getOrgRepoCtx(ctx) - if err != nil { - ctx.Handle(500, "getOrgRepoCtx", err) - return - } - ctx.Data["BaseLink"] = orCtx.Link - if ctx.HasError() { ctx.HTML(200, orCtx.NewTemplate) return @@ -588,6 +580,7 @@ func TriggerHook(ctx *middleware.Context) { return } models.HookQueue.AddRepoID(repo.ID) + ctx.Status(200) } func GitHooks(ctx *middleware.Context) { |