diff options
author | Unknwon <u@gogs.io> | 2017-02-21 15:44:35 -0500 |
---|---|---|
committer | Unknwon <u@gogs.io> | 2017-02-21 15:44:35 -0500 |
commit | bd970b8b27d648b3beff5cdec2f509826df0bb14 (patch) | |
tree | 25ee3516716ffd02864bacc60b85930a73db2bc2 /routers | |
parent | 0f3155660ebecdc4fd3e453a59b4e0f474d5e33c (diff) |
webhook: only trigger specific webhook for test delivery (#3030)
Diffstat (limited to 'routers')
-rw-r--r-- | routers/api/v1/repo/hook.go | 2 | ||||
-rw-r--r-- | routers/repo/webhook.go | 6 |
2 files changed, 4 insertions, 4 deletions
diff --git a/routers/api/v1/repo/hook.go b/routers/api/v1/repo/hook.go index 9857d2eb..fa66fe47 100644 --- a/routers/api/v1/repo/hook.go +++ b/routers/api/v1/repo/hook.go @@ -99,7 +99,7 @@ func CreateHook(ctx *context.APIContext, form api.CreateHookOption) { // https://github.com/gogits/go-gogs-client/wiki/Repositories#edit-a-hook func EditHook(ctx *context.APIContext, form api.EditHookOption) { - w, err := models.GetWebhookByRepoID(ctx.Repo.Repository.ID, ctx.ParamsInt64(":id")) + w, err := models.GetWebhookOfRepoByID(ctx.Repo.Repository.ID, ctx.ParamsInt64(":id")) if err != nil { if models.IsErrWebhookNotExist(err) { ctx.Status(404) diff --git a/routers/repo/webhook.go b/routers/repo/webhook.go index f033e41b..542fa635 100644 --- a/routers/repo/webhook.go +++ b/routers/repo/webhook.go @@ -273,7 +273,7 @@ func checkWebhook(ctx *context.Context) (*OrgRepoCtx, *models.Webhook) { var w *models.Webhook if orCtx.RepoID > 0 { - w, err = models.GetWebhookByRepoID(ctx.Repo.Repository.ID, ctx.ParamsInt64(":id")) + w, err = models.GetWebhookOfRepoByID(ctx.Repo.Repository.ID, ctx.ParamsInt64(":id")) } else { w, err = models.GetWebhookByOrgID(ctx.Org.Organization.ID, ctx.ParamsInt64(":id")) } @@ -504,8 +504,8 @@ func TestWebhook(ctx *context.Context) { Pusher: apiUser, Sender: apiUser, } - if err := models.PrepareWebhooks(ctx.Repo.Repository, models.HOOK_EVENT_PUSH, p); err != nil { - ctx.Flash.Error("PrepareWebhooks: " + err.Error()) + if err := models.TestWebhook(ctx.Repo.Repository, models.HOOK_EVENT_PUSH, p, ctx.QueryInt64("id")); err != nil { + ctx.Flash.Error("TestWebhook: " + err.Error()) ctx.Status(500) } else { go models.HookQueue.Add(ctx.Repo.Repository.ID) |