diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2017-08-29 22:55:24 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-08-29 22:55:24 +0800 |
commit | 3e6fed368bbd837854292d3855463d567a689943 (patch) | |
tree | dcdff5d6a9ab69f6bd41158ebfee615f208f9c64 /routers | |
parent | 491f0ebc58854560f72a5360060dac1fee3f1883 (diff) | |
download | gitea-3e6fed368bbd837854292d3855463d567a689943.tar.gz gitea-3e6fed368bbd837854292d3855463d567a689943.zip |
fix webhook test (#2415)
* fix webhook test
* fix error message
* fix typo
Diffstat (limited to 'routers')
-rw-r--r-- | routers/repo/webhook.go | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/routers/repo/webhook.go b/routers/repo/webhook.go index 58412997df..4011b6f0e6 100644 --- a/routers/repo/webhook.go +++ b/routers/repo/webhook.go @@ -545,6 +545,14 @@ func DiscordHooksEditPost(ctx *context.Context, form auth.NewDiscordHookForm) { // TestWebhook test if web hook is work fine func TestWebhook(ctx *context.Context) { + hookID := ctx.ParamsInt64(":id") + w, err := models.GetWebhookByRepoID(ctx.Repo.Repository.ID, hookID) + if err != nil { + ctx.Flash.Error("GetWebhookByID: " + err.Error()) + ctx.Status(500) + return + } + // Grab latest commit or fake one if it's empty repository. commit := ctx.Repo.Commit if commit == nil { @@ -581,8 +589,8 @@ func TestWebhook(ctx *context.Context) { Pusher: apiUser, Sender: apiUser, } - if err := models.PrepareWebhooks(ctx.Repo.Repository, models.HookEventPush, p); err != nil { - ctx.Flash.Error("PrepareWebhooks: " + err.Error()) + if err := models.PrepareWebhook(w, ctx.Repo.Repository, models.HookEventPush, p); err != nil { + ctx.Flash.Error("PrepareWebhook: " + err.Error()) ctx.Status(500) } else { go models.HookQueue.Add(ctx.Repo.Repository.ID) |