Browse Source

api: handle new events for hook

pull/4281/merge
Unknwon 8 years ago
parent
commit
f0209ac2f6
No known key found for this signature in database
GPG Key ID: 25B575AE3213B2B3
  1. 10
      routers/api/v1/repo/hook.go

10
routers/api/v1/repo/hook.go

@ -60,8 +60,13 @@ func CreateHook(ctx *context.APIContext, form api.CreateHookOption) {
ChooseEvents: true, ChooseEvents: true,
HookEvents: models.HookEvents{ HookEvents: models.HookEvents{
Create: com.IsSliceContainsStr(form.Events, string(models.HOOK_EVENT_CREATE)), 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)), 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)), PullRequest: com.IsSliceContainsStr(form.Events, string(models.HOOK_EVENT_PULL_REQUEST)),
Release: com.IsSliceContainsStr(form.Events, string(models.HOOK_EVENT_RELEASE)),
}, },
}, },
IsActive: form.Active, IsActive: form.Active,
@ -146,8 +151,13 @@ func EditHook(ctx *context.APIContext, form api.EditHookOption) {
w.SendEverything = false w.SendEverything = false
w.ChooseEvents = true w.ChooseEvents = true
w.Create = com.IsSliceContainsStr(form.Events, string(models.HOOK_EVENT_CREATE)) 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.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.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 { if err = w.UpdateEvent(); err != nil {
ctx.Error(500, "UpdateEvent", err) ctx.Error(500, "UpdateEvent", err)
return return

Loading…
Cancel
Save