summaryrefslogtreecommitdiffstats
path: root/routers/repo/webhook.go
diff options
context:
space:
mode:
Diffstat (limited to 'routers/repo/webhook.go')
-rw-r--r--routers/repo/webhook.go12
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)