@@ -101,11 +101,40 @@ func (n *actionsNotifier) IssueChangeStatus(ctx context.Context, doer *user_mode
101
101
Notify (ctx )
102
102
}
103
103
104
+ // IssueChangeAssignee notifies assigned or unassigned to notifiers
105
+ 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 ) {
106
+ ctx = withMethod (ctx , "IssueChangeAssignee" )
107
+
108
+ var action api.HookIssueAction
109
+ if removed {
110
+ action = api .HookIssueUnassigned
111
+ } else {
112
+ action = api .HookIssueAssigned
113
+ }
114
+ notifyIssueChange (ctx , doer , issue , webhook_module .HookEventPullRequestAssign , action )
115
+ }
116
+
117
+ // IssueChangeMilestone notifies assignee to notifiers
118
+ func (n * actionsNotifier ) IssueChangeMilestone (ctx context.Context , doer * user_model.User , issue * issues_model.Issue , oldMilestoneID int64 ) {
119
+ ctx = withMethod (ctx , "IssueChangeMilestone" )
120
+
121
+ var action api.HookIssueAction
122
+ if issue .MilestoneID > 0 {
123
+ action = api .HookIssueMilestoned
124
+ } else {
125
+ action = api .HookIssueDemilestoned
126
+ }
127
+ notifyIssueChange (ctx , doer , issue , webhook_module .HookEventPullRequestMilestone , action )
128
+ }
129
+
104
130
func (n * actionsNotifier ) IssueChangeLabels (ctx context.Context , doer * user_model.User , issue * issues_model.Issue ,
105
131
_ , _ []* issues_model.Label ,
106
132
) {
107
133
ctx = withMethod (ctx , "IssueChangeLabels" )
134
+ notifyIssueChange (ctx , doer , issue , webhook_module .HookEventPullRequestLabel , api .HookIssueLabelUpdated )
135
+ }
108
136
137
+ func notifyIssueChange (ctx context.Context , doer * user_model.User , issue * issues_model.Issue , event webhook_module.HookEventType , action api.HookIssueAction ) {
109
138
var err error
110
139
if err = issue .LoadRepo (ctx ); err != nil {
111
140
log .Error ("LoadRepo: %v" , err )
@@ -117,20 +146,15 @@ func (n *actionsNotifier) IssueChangeLabels(ctx context.Context, doer *user_mode
117
146
return
118
147
}
119
148
120
- permission , _ := access_model .GetUserRepoPermission (ctx , issue .Repo , issue .Poster )
121
149
if issue .IsPull {
122
150
if err = issue .LoadPullRequest (ctx ); err != nil {
123
151
log .Error ("loadPullRequest: %v" , err )
124
152
return
125
153
}
126
- if err = issue .PullRequest .LoadIssue (ctx ); err != nil {
127
- log .Error ("LoadIssue: %v" , err )
128
- return
129
- }
130
- newNotifyInputFromIssue (issue , webhook_module .HookEventPullRequestLabel ).
154
+ newNotifyInputFromIssue (issue , event ).
131
155
WithDoer (doer ).
132
156
WithPayload (& api.PullRequestPayload {
133
- Action : api . HookIssueLabelUpdated ,
157
+ Action : action ,
134
158
Index : issue .Index ,
135
159
PullRequest : convert .ToAPIPullRequest (ctx , issue .PullRequest , nil ),
136
160
Repository : convert .ToRepo (ctx , issue .Repo , access_model.Permission {AccessMode : perm_model .AccessModeNone }),
@@ -140,10 +164,11 @@ func (n *actionsNotifier) IssueChangeLabels(ctx context.Context, doer *user_mode
140
164
Notify (ctx )
141
165
return
142
166
}
143
- newNotifyInputFromIssue (issue , webhook_module .HookEventIssueLabel ).
167
+ permission , _ := access_model .GetUserRepoPermission (ctx , issue .Repo , issue .Poster )
168
+ newNotifyInputFromIssue (issue , event ).
144
169
WithDoer (doer ).
145
170
WithPayload (& api.IssuePayload {
146
- Action : api . HookIssueLabelUpdated ,
171
+ Action : action ,
147
172
Index : issue .Index ,
148
173
Issue : convert .ToAPIIssue (ctx , issue ),
149
174
Repository : convert .ToRepo (ctx , issue .Repo , permission ),
@@ -305,6 +330,39 @@ func (n *actionsNotifier) PullRequestReview(ctx context.Context, pr *issues_mode
305
330
}).Notify (ctx )
306
331
}
307
332
333
+ 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 ) {
334
+ if ! issue .IsPull {
335
+ log .Warn ("PullRequestReviewRequest: issue is not a pull request: %v" , issue .ID )
336
+ return
337
+ }
338
+
339
+ ctx = withMethod (ctx , "PullRequestReviewRequest" )
340
+
341
+ permission , _ := access_model .GetUserRepoPermission (ctx , issue .Repo , doer )
342
+ if err := issue .LoadPullRequest (ctx ); err != nil {
343
+ log .Error ("LoadPullRequest failed: %v" , err )
344
+ return
345
+ }
346
+ var action api.HookIssueAction
347
+ if isRequest {
348
+ action = api .HookIssueReviewRequested
349
+ } else {
350
+ action = api .HookIssueReviewRequestRemoved
351
+ }
352
+ newNotifyInputFromIssue (issue , webhook_module .HookEventPullRequestReviewRequest ).
353
+ WithDoer (doer ).
354
+ WithPayload (& api.PullRequestPayload {
355
+ Action : action ,
356
+ Index : issue .Index ,
357
+ PullRequest : convert .ToAPIPullRequest (ctx , issue .PullRequest , nil ),
358
+ RequestedReviewer : convert .ToUser (ctx , reviewer , nil ),
359
+ Repository : convert .ToRepo (ctx , issue .Repo , permission ),
360
+ Sender : convert .ToUser (ctx , doer , nil ),
361
+ }).
362
+ WithPullRequest (issue .PullRequest ).
363
+ Notify (ctx )
364
+ }
365
+
308
366
func (* actionsNotifier ) MergePullRequest (ctx context.Context , doer * user_model.User , pr * issues_model.PullRequest ) {
309
367
ctx = withMethod (ctx , "MergePullRequest" )
310
368
0 commit comments