From f0209ac2f692226a10e8b8b9875e49adcf316779 Mon Sep 17 00:00:00 2001 From: Unknwon Date: Mon, 13 Mar 2017 14:32:16 -0400 Subject: [PATCH] api: handle new events for hook --- routers/api/v1/repo/hook.go | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/routers/api/v1/repo/hook.go b/routers/api/v1/repo/hook.go index 466d3625c..ca8817dc3 100644 --- a/routers/api/v1/repo/hook.go +++ b/routers/api/v1/repo/hook.go @@ -59,9 +59,14 @@ func CreateHook(ctx *context.APIContext, form api.CreateHookOption) { HookEvent: &models.HookEvent{ ChooseEvents: true, HookEvents: models.HookEvents{ - Create: com.IsSliceContainsStr(form.Events, string(models.HOOK_EVENT_CREATE)), - Push: com.IsSliceContainsStr(form.Events, string(models.HOOK_EVENT_PUSH)), - PullRequest: com.IsSliceContainsStr(form.Events, string(models.HOOK_EVENT_PULL_REQUEST)), + Create: com.IsSliceContainsStr(form.Events, string(models.HOOK_EVENT_CREATE)), + Delete: com.IsSliceContainsStr(form.Events, string(models.HOOK_EVENT_DELETE)), + Fork: com.IsSliceContainsStr(form.Events, string(models.HOOK_EVENT_FORK)), + Push: com.IsSliceContainsStr(form.Events, string(models.HOOK_EVENT_PUSH)), + Issues: com.IsSliceContainsStr(form.Events, string(models.HOOK_EVENT_ISSUES)), + IssueComment: com.IsSliceContainsStr(form.Events, string(models.HOOK_EVENT_ISSUE_COMMENT)), + PullRequest: com.IsSliceContainsStr(form.Events, string(models.HOOK_EVENT_PULL_REQUEST)), + Release: com.IsSliceContainsStr(form.Events, string(models.HOOK_EVENT_RELEASE)), }, }, IsActive: form.Active, @@ -146,8 +151,13 @@ func EditHook(ctx *context.APIContext, form api.EditHookOption) { w.SendEverything = false w.ChooseEvents = true w.Create = com.IsSliceContainsStr(form.Events, string(models.HOOK_EVENT_CREATE)) + w.Delete = com.IsSliceContainsStr(form.Events, string(models.HOOK_EVENT_DELETE)) + w.Fork = com.IsSliceContainsStr(form.Events, string(models.HOOK_EVENT_FORK)) w.Push = com.IsSliceContainsStr(form.Events, string(models.HOOK_EVENT_PUSH)) + w.Issues = com.IsSliceContainsStr(form.Events, string(models.HOOK_EVENT_ISSUES)) + w.IssueComment = com.IsSliceContainsStr(form.Events, string(models.HOOK_EVENT_ISSUE_COMMENT)) w.PullRequest = com.IsSliceContainsStr(form.Events, string(models.HOOK_EVENT_PULL_REQUEST)) + w.Release = com.IsSliceContainsStr(form.Events, string(models.HOOK_EVENT_RELEASE)) if err = w.UpdateEvent(); err != nil { ctx.Error(500, "UpdateEvent", err) return