@@ -168,7 +168,7 @@ func (n *actionsNotifier) IssueChangeAssignee(ctx context.Context, doer *user_mo
168168 hookEvent = webhook_module .HookEventPullRequestAssign
169169 }
170170
171- notifyIssueChange (ctx , doer , issue , hookEvent , action )
171+ notifyIssueChange (ctx , doer , issue , hookEvent , action , nil )
172172}
173173
174174// IssueChangeMilestone notifies assignee to notifiers
@@ -187,11 +187,11 @@ func (n *actionsNotifier) IssueChangeMilestone(ctx context.Context, doer *user_m
187187 hookEvent = webhook_module .HookEventPullRequestMilestone
188188 }
189189
190- notifyIssueChange (ctx , doer , issue , hookEvent , action )
190+ notifyIssueChange (ctx , doer , issue , hookEvent , action , nil )
191191}
192192
193193func (n * actionsNotifier ) IssueChangeLabels (ctx context.Context , doer * user_model.User , issue * issues_model.Issue ,
194- _ , _ []* issues_model.Label ,
194+ addedLabels , removedLabels []* issues_model.Label ,
195195) {
196196 ctx = withMethod (ctx , "IssueChangeLabels" )
197197
@@ -200,10 +200,15 @@ func (n *actionsNotifier) IssueChangeLabels(ctx context.Context, doer *user_mode
200200 hookEvent = webhook_module .HookEventPullRequestLabel
201201 }
202202
203- notifyIssueChange (ctx , doer , issue , hookEvent , api .HookIssueLabelUpdated )
203+ for _ , added := range addedLabels {
204+ notifyIssueChange (ctx , doer , issue , hookEvent , api .HookIssueLabelUpdated , added )
205+ }
206+ for _ , removed := range removedLabels {
207+ notifyIssueChange (ctx , doer , issue , hookEvent , api .HookIssueLabelCleared , removed )
208+ }
204209}
205210
206- func notifyIssueChange (ctx context.Context , doer * user_model.User , issue * issues_model.Issue , event webhook_module.HookEventType , action api.HookIssueAction ) {
211+ func notifyIssueChange (ctx context.Context , doer * user_model.User , issue * issues_model.Issue , event webhook_module.HookEventType , action api.HookIssueAction , label * issues_model. Label ) {
207212 var err error
208213 if err = issue .LoadRepo (ctx ); err != nil {
209214 log .Error ("LoadRepo: %v" , err )
@@ -215,6 +220,11 @@ func notifyIssueChange(ctx context.Context, doer *user_model.User, issue *issues
215220 return
216221 }
217222
223+ var apiLabel * api.Label
224+ if action == api .HookIssueLabelUpdated || action == api .HookIssueLabelCleared {
225+ apiLabel = convert .ToLabel (label , issue .Repo , nil )
226+ }
227+
218228 if issue .IsPull {
219229 if err = issue .LoadPullRequest (ctx ); err != nil {
220230 log .Error ("loadPullRequest: %v" , err )
@@ -228,6 +238,7 @@ func notifyIssueChange(ctx context.Context, doer *user_model.User, issue *issues
228238 PullRequest : convert .ToAPIPullRequest (ctx , issue .PullRequest , nil ),
229239 Repository : convert .ToRepo (ctx , issue .Repo , access_model.Permission {AccessMode : perm_model .AccessModeNone }),
230240 Sender : convert .ToUser (ctx , doer , nil ),
241+ Label : apiLabel ,
231242 }).
232243 WithPullRequest (issue .PullRequest ).
233244 Notify (ctx )
@@ -242,6 +253,7 @@ func notifyIssueChange(ctx context.Context, doer *user_model.User, issue *issues
242253 Issue : convert .ToAPIIssue (ctx , doer , issue ),
243254 Repository : convert .ToRepo (ctx , issue .Repo , permission ),
244255 Sender : convert .ToUser (ctx , doer , nil ),
256+ Label : apiLabel ,
245257 }).
246258 Notify (ctx )
247259}
0 commit comments