@@ -102,11 +102,40 @@ func (n *actionsNotifier) IssueChangeStatus(ctx context.Context, doer *user_mode
102102 Notify (ctx )
103103}
104104
105+ // IssueChangeAssignee notifies assigned or unassigned to notifiers
106+ 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 ) {
107+ ctx = withMethod (ctx , "IssueChangeAssignee" )
108+
109+ var action api.HookIssueAction
110+ if removed {
111+ action = api .HookIssueUnassigned
112+ } else {
113+ action = api .HookIssueAssigned
114+ }
115+ notifyIssueChange (ctx , doer , issue , webhook_module .HookEventPullRequestAssign , action )
116+ }
117+
118+ // IssueChangeMilestone notifies assignee to notifiers
119+ func (n * actionsNotifier ) IssueChangeMilestone (ctx context.Context , doer * user_model.User , issue * issues_model.Issue , oldMilestoneID int64 ) {
120+ ctx = withMethod (ctx , "IssueChangeMilestone" )
121+
122+ var action api.HookIssueAction
123+ if issue .MilestoneID > 0 {
124+ action = api .HookIssueMilestoned
125+ } else {
126+ action = api .HookIssueDemilestoned
127+ }
128+ notifyIssueChange (ctx , doer , issue , webhook_module .HookEventPullRequestMilestone , action )
129+ }
130+
105131func (n * actionsNotifier ) IssueChangeLabels (ctx context.Context , doer * user_model.User , issue * issues_model.Issue ,
106132 _ , _ []* issues_model.Label ,
107133) {
108134 ctx = withMethod (ctx , "IssueChangeLabels" )
135+ notifyIssueChange (ctx , doer , issue , webhook_module .HookEventPullRequestLabel , api .HookIssueLabelUpdated )
136+ }
109137
138+ func notifyIssueChange (ctx context.Context , doer * user_model.User , issue * issues_model.Issue , event webhook_module.HookEventType , action api.HookIssueAction ) {
110139 var err error
111140 if err = issue .LoadRepo (ctx ); err != nil {
112141 log .Error ("LoadRepo: %v" , err )
@@ -118,20 +147,15 @@ func (n *actionsNotifier) IssueChangeLabels(ctx context.Context, doer *user_mode
118147 return
119148 }
120149
121- permission , _ := access_model .GetUserRepoPermission (ctx , issue .Repo , issue .Poster )
122150 if issue .IsPull {
123151 if err = issue .LoadPullRequest (ctx ); err != nil {
124152 log .Error ("loadPullRequest: %v" , err )
125153 return
126154 }
127- if err = issue .PullRequest .LoadIssue (ctx ); err != nil {
128- log .Error ("LoadIssue: %v" , err )
129- return
130- }
131- newNotifyInputFromIssue (issue , webhook_module .HookEventPullRequestLabel ).
155+ newNotifyInputFromIssue (issue , event ).
132156 WithDoer (doer ).
133157 WithPayload (& api.PullRequestPayload {
134- Action : api . HookIssueLabelUpdated ,
158+ Action : action ,
135159 Index : issue .Index ,
136160 PullRequest : convert .ToAPIPullRequest (ctx , issue .PullRequest , nil ),
137161 Repository : convert .ToRepo (ctx , issue .Repo , access_model.Permission {AccessMode : perm_model .AccessModeNone }),
@@ -141,10 +165,11 @@ func (n *actionsNotifier) IssueChangeLabels(ctx context.Context, doer *user_mode
141165 Notify (ctx )
142166 return
143167 }
144- newNotifyInputFromIssue (issue , webhook_module .HookEventIssueLabel ).
168+ permission , _ := access_model .GetUserRepoPermission (ctx , issue .Repo , issue .Poster )
169+ newNotifyInputFromIssue (issue , event ).
145170 WithDoer (doer ).
146171 WithPayload (& api.IssuePayload {
147- Action : api . HookIssueLabelUpdated ,
172+ Action : action ,
148173 Index : issue .Index ,
149174 Issue : convert .ToAPIIssue (ctx , issue ),
150175 Repository : convert .ToRepo (ctx , issue .Repo , permission ),
@@ -306,6 +331,39 @@ func (n *actionsNotifier) PullRequestReview(ctx context.Context, pr *issues_mode
306331 }).Notify (ctx )
307332}
308333
334+ 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 ) {
335+ if ! issue .IsPull {
336+ log .Warn ("PullRequestReviewRequest: issue is not a pull request: %v" , issue .ID )
337+ return
338+ }
339+
340+ ctx = withMethod (ctx , "PullRequestReviewRequest" )
341+
342+ permission , _ := access_model .GetUserRepoPermission (ctx , issue .Repo , doer )
343+ if err := issue .LoadPullRequest (ctx ); err != nil {
344+ log .Error ("LoadPullRequest failed: %v" , err )
345+ return
346+ }
347+ var action api.HookIssueAction
348+ if isRequest {
349+ action = api .HookIssueReviewRequested
350+ } else {
351+ action = api .HookIssueReviewRequestRemoved
352+ }
353+ newNotifyInputFromIssue (issue , webhook_module .HookEventPullRequestReviewRequest ).
354+ WithDoer (doer ).
355+ WithPayload (& api.PullRequestPayload {
356+ Action : action ,
357+ Index : issue .Index ,
358+ PullRequest : convert .ToAPIPullRequest (ctx , issue .PullRequest , nil ),
359+ RequestedReviewer : convert .ToUser (ctx , reviewer , nil ),
360+ Repository : convert .ToRepo (ctx , issue .Repo , permission ),
361+ Sender : convert .ToUser (ctx , doer , nil ),
362+ }).
363+ WithPullRequest (issue .PullRequest ).
364+ Notify (ctx )
365+ }
366+
309367func (* actionsNotifier ) MergePullRequest (ctx context.Context , doer * user_model.User , pr * issues_model.PullRequest ) {
310368 ctx = withMethod (ctx , "MergePullRequest" )
311369
0 commit comments