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. 16
      routers/api/v1/repo/hook.go

16
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

Loading…
Cancel
Save