Skip to content

Commit 3ecd520

Browse files
authored
Granular webhook events in editHook (#19251) (#19257)
Signed-off-by: jolheiser <[email protected]>
1 parent e9935d3 commit 3ecd520

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

routers/api/v1/utils/hook.go

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -246,18 +246,29 @@ func editHook(ctx *context.APIContext, form *api.EditHookOption, w *webhook.Webh
246246
w.ChooseEvents = true
247247
w.Create = util.IsStringInSlice(string(webhook.HookEventCreate), form.Events, true)
248248
w.Push = util.IsStringInSlice(string(webhook.HookEventPush), form.Events, true)
249-
w.PullRequest = util.IsStringInSlice(string(webhook.HookEventPullRequest), form.Events, true)
250249
w.Create = util.IsStringInSlice(string(webhook.HookEventCreate), form.Events, true)
251250
w.Delete = util.IsStringInSlice(string(webhook.HookEventDelete), form.Events, true)
252251
w.Fork = util.IsStringInSlice(string(webhook.HookEventFork), form.Events, true)
253-
w.Issues = util.IsStringInSlice(string(webhook.HookEventIssues), form.Events, true)
254-
w.IssueComment = util.IsStringInSlice(string(webhook.HookEventIssueComment), form.Events, true)
255-
w.Push = util.IsStringInSlice(string(webhook.HookEventPush), form.Events, true)
256-
w.PullRequest = util.IsStringInSlice(string(webhook.HookEventPullRequest), form.Events, true)
257252
w.Repository = util.IsStringInSlice(string(webhook.HookEventRepository), form.Events, true)
258253
w.Release = util.IsStringInSlice(string(webhook.HookEventRelease), form.Events, true)
259254
w.BranchFilter = form.BranchFilter
260255

256+
// Issues
257+
w.Issues = issuesHook(form.Events, "issues_only")
258+
w.IssueAssign = issuesHook(form.Events, string(webhook.HookEventIssueAssign))
259+
w.IssueLabel = issuesHook(form.Events, string(webhook.HookEventIssueLabel))
260+
w.IssueMilestone = issuesHook(form.Events, string(webhook.HookEventIssueMilestone))
261+
w.IssueComment = issuesHook(form.Events, string(webhook.HookEventIssueComment))
262+
263+
// Pull requests
264+
w.PullRequest = pullHook(form.Events, "pull_request_only")
265+
w.PullRequestAssign = pullHook(form.Events, string(webhook.HookEventPullRequestAssign))
266+
w.PullRequestLabel = pullHook(form.Events, string(webhook.HookEventPullRequestLabel))
267+
w.PullRequestMilestone = pullHook(form.Events, string(webhook.HookEventPullRequestMilestone))
268+
w.PullRequestComment = pullHook(form.Events, string(webhook.HookEventPullRequestComment))
269+
w.PullRequestReview = pullHook(form.Events, "pull_request_review")
270+
w.PullRequestSync = pullHook(form.Events, string(webhook.HookEventPullRequestSync))
271+
261272
if err := w.UpdateEvent(); err != nil {
262273
ctx.Error(http.StatusInternalServerError, "UpdateEvent", err)
263274
return false

0 commit comments

Comments
 (0)