@ -169,7 +169,7 @@ func (n *actionsNotifier) IssueChangeAssignee(ctx context.Context, doer *user_mo
hookEvent = webhook_module . HookEventPullRequestAssign
hookEvent = webhook_module . HookEventPullRequestAssign
}
}
notifyIssueChange ( ctx , doer , issue , hookEvent , action )
notifyIssueChange ( ctx , doer , issue , hookEvent , action , nil , nil )
}
}
// IssueChangeMilestone notifies assignee to notifiers
// IssueChangeMilestone notifies assignee to notifiers
@ -188,11 +188,11 @@ func (n *actionsNotifier) IssueChangeMilestone(ctx context.Context, doer *user_m
hookEvent = webhook_module . HookEventPullRequestMilestone
hookEvent = webhook_module . HookEventPullRequestMilestone
}
}
notifyIssueChange ( ctx , doer , issue , hookEvent , action )
notifyIssueChange ( ctx , doer , issue , hookEvent , action , nil , nil )
}
}
func ( n * actionsNotifier ) IssueChangeLabels ( ctx context . Context , doer * user_model . User , issue * issues_model . Issue ,
func ( n * actionsNotifier ) IssueChangeLabels ( ctx context . Context , doer * user_model . User , issue * issues_model . Issue ,
_, _ [ ] * issues_model . Label ,
addedLabels, removedLabels [ ] * issues_model . Label ,
) {
) {
ctx = withMethod ( ctx , "IssueChangeLabels" )
ctx = withMethod ( ctx , "IssueChangeLabels" )
@ -201,10 +201,10 @@ func (n *actionsNotifier) IssueChangeLabels(ctx context.Context, doer *user_mode
hookEvent = webhook_module . HookEventPullRequestLabel
hookEvent = webhook_module . HookEventPullRequestLabel
}
}
notifyIssueChange ( ctx , doer , issue , hookEvent , api . HookIssueLabelUpdated )
notifyIssueChange ( ctx , doer , issue , hookEvent , api . HookIssueLabelUpdated , addedLabels , removedLabels )
}
}
func notifyIssueChange ( ctx context . Context , doer * user_model . User , issue * issues_model . Issue , event webhook_module . HookEventType , action api . HookIssueAction ) {
func notifyIssueChange ( ctx context . Context , doer * user_model . User , issue * issues_model . Issue , event webhook_module . HookEventType , action api . HookIssueAction , addedLabels , removedLabels [ ] * issues_model . Label ) {
var err error
var err error
if err = issue . LoadRepo ( ctx ) ; err != nil {
if err = issue . LoadRepo ( ctx ) ; err != nil {
log . Error ( "LoadRepo: %v" , err )
log . Error ( "LoadRepo: %v" , err )
@ -216,34 +216,65 @@ func notifyIssueChange(ctx context.Context, doer *user_model.User, issue *issues
return
return
}
}
var addedAPILabels [ ] * api . Label
if addedLabels != nil {
addedAPILabels = make ( [ ] * api . Label , 0 , len ( addedLabels ) )
for _ , label := range addedLabels {
addedAPILabels = append ( addedAPILabels , convert . ToLabel ( label , issue . Repo , doer ) )
}
}
// Get removed labels from context if present
var removedAPILabels [ ] * api . Label
if removedLabels != nil {
removedAPILabels = make ( [ ] * api . Label , 0 , len ( removedLabels ) )
for _ , label := range removedLabels {
removedAPILabels = append ( removedAPILabels , convert . ToLabel ( label , issue . Repo , doer ) )
}
}
if issue . IsPull {
if issue . IsPull {
if err = issue . LoadPullRequest ( ctx ) ; err != nil {
if err = issue . LoadPullRequest ( ctx ) ; err != nil {
log . Error ( "loadPullRequest: %v" , err )
log . Error ( "loadPullRequest: %v" , err )
return
return
}
}
newNotifyInputFromIssue ( issue , event ) .
WithDoer ( doer ) .
payload := & api . PullRequestPayload {
WithPayload ( & api . PullRequestPayload {
Action : action ,
Action : action ,
Index : issue . Index ,
Index : issue . Index ,
PullRequest : convert . ToAPIPullRequest ( ctx , issue . PullRequest , nil ) ,
PullRequest : convert . ToAPIPullRequest ( ctx , issue . PullRequest , nil ) ,
Repository : convert . ToRepo ( ctx , issue . Repo , access_model . Permission { AccessMode : perm_model . AccessModeNone } ) ,
Repository : convert . ToRepo ( ctx , issue . Repo , access_model . Permission { AccessMode : perm_model . AccessModeNone } ) ,
Sender : convert . ToUser ( ctx , doer , nil ) ,
Sender : convert . ToUser ( ctx , doer , nil ) ,
} ) .
Changes : & api . ChangesPayload {
AddedLabels : addedAPILabels ,
RemovedLabels : removedAPILabels ,
} ,
}
newNotifyInputFromIssue ( issue , event ) .
WithDoer ( doer ) .
WithPayload ( payload ) .
WithPullRequest ( issue . PullRequest ) .
WithPullRequest ( issue . PullRequest ) .
Notify ( ctx )
Notify ( ctx )
return
return
}
}
permission , _ := access_model . GetUserRepoPermission ( ctx , issue . Repo , issue . Poster )
permission , _ := access_model . GetUserRepoPermission ( ctx , issue . Repo , issue . Poster )
newNotifyInputFromIssue ( issue , event ) .
payload := & api . IssuePayload {
WithDoer ( doer ) .
WithPayload ( & api . IssuePayload {
Action : action ,
Action : action ,
Index : issue . Index ,
Index : issue . Index ,
Issue : convert . ToAPIIssue ( ctx , doer , issue ) ,
Issue : convert . ToAPIIssue ( ctx , doer , issue ) ,
Repository : convert . ToRepo ( ctx , issue . Repo , permission ) ,
Repository : convert . ToRepo ( ctx , issue . Repo , permission ) ,
Sender : convert . ToUser ( ctx , doer , nil ) ,
Sender : convert . ToUser ( ctx , doer , nil ) ,
} ) .
Changes : & api . ChangesPayload {
AddedLabels : addedAPILabels ,
RemovedLabels : removedAPILabels ,
} ,
}
newNotifyInputFromIssue ( issue , event ) .
WithDoer ( doer ) .
WithPayload ( payload ) .
Notify ( ctx )
Notify ( ctx )
}
}