@@ -101,11 +101,40 @@ func (n *actionsNotifier) IssueChangeStatus(ctx context.Context, doer *user_mode
101101 Notify (ctx )
102102}
103103
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+
104130func (n * actionsNotifier ) IssueChangeLabels (ctx context.Context , doer * user_model.User , issue * issues_model.Issue ,
105131 _ , _ []* issues_model.Label ,
106132) {
107133 ctx = withMethod (ctx , "IssueChangeLabels" )
134+ notifyIssueChange (ctx , doer , issue , webhook_module .HookEventPullRequestLabel , api .HookIssueLabelUpdated )
135+ }
108136
137+ func notifyIssueChange (ctx context.Context , doer * user_model.User , issue * issues_model.Issue , event webhook_module.HookEventType , action api.HookIssueAction ) {
109138 var err error
110139 if err = issue .LoadRepo (ctx ); err != nil {
111140 log .Error ("LoadRepo: %v" , err )
@@ -117,20 +146,15 @@ func (n *actionsNotifier) IssueChangeLabels(ctx context.Context, doer *user_mode
117146 return
118147 }
119148
120- permission , _ := access_model .GetUserRepoPermission (ctx , issue .Repo , issue .Poster )
121149 if issue .IsPull {
122150 if err = issue .LoadPullRequest (ctx ); err != nil {
123151 log .Error ("loadPullRequest: %v" , err )
124152 return
125153 }
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 ).
131155 WithDoer (doer ).
132156 WithPayload (& api.PullRequestPayload {
133- Action : api . HookIssueLabelUpdated ,
157+ Action : action ,
134158 Index : issue .Index ,
135159 PullRequest : convert .ToAPIPullRequest (ctx , issue .PullRequest , nil ),
136160 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
140164 Notify (ctx )
141165 return
142166 }
143- newNotifyInputFromIssue (issue , webhook_module .HookEventIssueLabel ).
167+ permission , _ := access_model .GetUserRepoPermission (ctx , issue .Repo , issue .Poster )
168+ newNotifyInputFromIssue (issue , event ).
144169 WithDoer (doer ).
145170 WithPayload (& api.IssuePayload {
146- Action : api . HookIssueLabelUpdated ,
171+ Action : action ,
147172 Index : issue .Index ,
148173 Issue : convert .ToAPIIssue (ctx , issue ),
149174 Repository : convert .ToRepo (ctx , issue .Repo , permission ),
@@ -305,6 +330,39 @@ func (n *actionsNotifier) PullRequestReview(ctx context.Context, pr *issues_mode
305330 }).Notify (ctx )
306331}
307332
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+
308366func (* actionsNotifier ) MergePullRequest (ctx context.Context , doer * user_model.User , pr * issues_model.PullRequest ) {
309367 ctx = withMethod (ctx , "MergePullRequest" )
310368
0 commit comments