@@ -143,11 +143,40 @@ func (n *actionsNotifier) IssueChangeStatus(ctx context.Context, doer *user_mode
143
143
Notify(ctx)
144
144
}
145
145
146
+ // IssueChangeAssignee notifies assigned or unassigned to notifiers
147
+ func (n *actionsNotifier) IssueChangeAssignee(ctx context.Context, doer *user_model.User, issue *issues_model.Issue, assignee *user_model.User, removed bool, comment *issues_model.Comment) {
148
+ ctx = withMethod(ctx, "IssueChangeAssignee")
149
+
150
+ var action api.HookIssueAction
151
+ if removed {
152
+ action = api.HookIssueUnassigned
153
+ } else {
154
+ action = api.HookIssueAssigned
155
+ }
156
+ notifyIssueChange(ctx, doer, issue, webhook_module.HookEventPullRequestAssign, action)
157
+ }
158
+
159
+ // IssueChangeMilestone notifies assignee to notifiers
160
+ func (n *actionsNotifier) IssueChangeMilestone(ctx context.Context, doer *user_model.User, issue *issues_model.Issue, oldMilestoneID int64) {
161
+ ctx = withMethod(ctx, "IssueChangeMilestone")
162
+
163
+ var action api.HookIssueAction
164
+ if issue.MilestoneID > 0 {
165
+ action = api.HookIssueMilestoned
166
+ } else {
167
+ action = api.HookIssueDemilestoned
168
+ }
169
+ notifyIssueChange(ctx, doer, issue, webhook_module.HookEventPullRequestMilestone, action)
170
+ }
171
+
146
172
func (n *actionsNotifier) IssueChangeLabels(ctx context.Context, doer *user_model.User, issue *issues_model.Issue,
147
173
_, _ []*issues_model.Label,
148
174
) {
149
175
ctx = withMethod(ctx, "IssueChangeLabels")
176
+ notifyIssueChange(ctx, doer, issue, webhook_module.HookEventPullRequestLabel, api.HookIssueLabelUpdated)
177
+ }
150
178
179
+ func notifyIssueChange(ctx context.Context, doer *user_model.User, issue *issues_model.Issue, event webhook_module.HookEventType, action api.HookIssueAction) {
151
180
var err error
152
181
if err = issue.LoadRepo(ctx); err != nil {
153
182
log.Error("LoadRepo: %v", err)
@@ -159,20 +188,15 @@ func (n *actionsNotifier) IssueChangeLabels(ctx context.Context, doer *user_mode
159
188
return
160
189
}
161
190
162
- permission, _ := access_model.GetUserRepoPermission(ctx, issue.Repo, issue.Poster)
163
191
if issue.IsPull {
164
192
if err = issue.LoadPullRequest(ctx); err != nil {
165
193
log.Error("loadPullRequest: %v", err)
166
194
return
167
195
}
168
- if err = issue.PullRequest.LoadIssue(ctx); err != nil {
169
- log.Error("LoadIssue: %v", err)
170
- return
171
- }
172
- newNotifyInputFromIssue(issue, webhook_module.HookEventPullRequestLabel).
196
+ newNotifyInputFromIssue(issue, event).
173
197
WithDoer(doer).
174
198
WithPayload(&api.PullRequestPayload{
175
- Action: api.HookIssueLabelUpdated ,
199
+ Action: action ,
176
200
Index: issue.Index,
177
201
PullRequest: convert.ToAPIPullRequest(ctx, issue.PullRequest, nil),
178
202
Repository: convert.ToRepo(ctx, issue.Repo, access_model.Permission{AccessMode: perm_model.AccessModeNone}),
@@ -182,10 +206,11 @@ func (n *actionsNotifier) IssueChangeLabels(ctx context.Context, doer *user_mode
182
206
Notify(ctx)
183
207
return
184
208
}
185
- newNotifyInputFromIssue(issue, webhook_module.HookEventIssueLabel).
209
+ permission, _ := access_model.GetUserRepoPermission(ctx, issue.Repo, issue.Poster)
210
+ newNotifyInputFromIssue(issue, event).
186
211
WithDoer(doer).
187
212
WithPayload(&api.IssuePayload{
188
- Action: api.HookIssueLabelUpdated ,
213
+ Action: action ,
189
214
Index: issue.Index,
190
215
Issue: convert.ToAPIIssue(ctx, issue),
191
216
Repository: convert.ToRepo(ctx, issue.Repo, permission),
@@ -347,6 +372,39 @@ func (n *actionsNotifier) PullRequestReview(ctx context.Context, pr *issues_mode
347
372
}).Notify(ctx)
348
373
}
349
374
375
+ func (n *actionsNotifier) PullRequestReviewRequest(ctx context.Context, doer *user_model.User, issue *issues_model.Issue, reviewer *user_model.User, isRequest bool, comment *issues_model.Comment) {
376
+ if !issue.IsPull {
377
+ log.Warn("PullRequestReviewRequest: issue is not a pull request: %v", issue.ID)
378
+ return
379
+ }
380
+
381
+ ctx = withMethod(ctx, "PullRequestReviewRequest")
382
+
383
+ permission, _ := access_model.GetUserRepoPermission(ctx, issue.Repo, doer)
384
+ if err := issue.LoadPullRequest(ctx); err != nil {
385
+ log.Error("LoadPullRequest failed: %v", err)
386
+ return
387
+ }
388
+ var action api.HookIssueAction
389
+ if isRequest {
390
+ action = api.HookIssueReviewRequested
391
+ } else {
392
+ action = api.HookIssueReviewRequestRemoved
393
+ }
394
+ newNotifyInputFromIssue(issue, webhook_module.HookEventPullRequestReviewRequest).
395
+ WithDoer(doer).
396
+ WithPayload(&api.PullRequestPayload{
397
+ Action: action,
398
+ Index: issue.Index,
399
+ PullRequest: convert.ToAPIPullRequest(ctx, issue.PullRequest, nil),
400
+ RequestedReviewer: convert.ToUser(ctx, reviewer, nil),
401
+ Repository: convert.ToRepo(ctx, issue.Repo, permission),
402
+ Sender: convert.ToUser(ctx, doer, nil),
403
+ }).
404
+ WithPullRequest(issue.PullRequest).
405
+ Notify(ctx)
406
+ }
407
+
350
408
func (*actionsNotifier) MergePullRequest(ctx context.Context, doer *user_model.User, pr *issues_model.PullRequest) {
351
409
ctx = withMethod(ctx, "MergePullRequest")
352
410
0 commit comments