@ -101,11 +101,40 @@ func (n *actionsNotifier) IssueChangeStatus(ctx context.Context, doer *user_mode
Notify ( ctx )
}
// IssueChangeAssignee notifies assigned or unassigned to notifiers
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 ) {
ctx = withMethod ( ctx , "IssueChangeAssignee" )
var action api . HookIssueAction
if removed {
action = api . HookIssueUnassigned
} else {
action = api . HookIssueAssigned
}
notifyIssueChange ( ctx , doer , issue , webhook_module . HookEventPullRequestAssign , action )
}
// IssueChangeMilestone notifies assignee to notifiers
func ( n * actionsNotifier ) IssueChangeMilestone ( ctx context . Context , doer * user_model . User , issue * issues_model . Issue , oldMilestoneID int64 ) {
ctx = withMethod ( ctx , "IssueChangeMilestone" )
var action api . HookIssueAction
if issue . MilestoneID > 0 {
action = api . HookIssueMilestoned
} else {
action = api . HookIssueDemilestoned
}
notifyIssueChange ( ctx , doer , issue , webhook_module . HookEventPullRequestMilestone , action )
}
func ( n * actionsNotifier ) IssueChangeLabels ( ctx context . Context , doer * user_model . User , issue * issues_model . Issue ,
_ , _ [ ] * issues_model . Label ,
) {
ctx = withMethod ( ctx , "IssueChangeLabels" )
notifyIssueChange ( ctx , doer , issue , webhook_module . HookEventPullRequestLabel , api . HookIssueLabelUpdated )
}
func notifyIssueChange ( ctx context . Context , doer * user_model . User , issue * issues_model . Issue , event webhook_module . HookEventType , action api . HookIssueAction ) {
var err error
if err = issue . LoadRepo ( ctx ) ; err != nil {
log . Error ( "LoadRepo: %v" , err )
@ -117,20 +146,15 @@ func (n *actionsNotifier) IssueChangeLabels(ctx context.Context, doer *user_mode
return
}
permission , _ := access_model . GetUserRepoPermission ( ctx , issue . Repo , issue . Poster )
if issue . IsPull {
if err = issue . LoadPullRequest ( ctx ) ; err != nil {
log . Error ( "loadPullRequest: %v" , err )
return
}
if err = issue . PullRequest . LoadIssue ( ctx ) ; err != nil {
log . Error ( "LoadIssue: %v" , err )
return
}
newNotifyInputFromIssue ( issue , webhook_module . HookEventPullRequestLabel ) .
newNotifyInputFromIssue ( issue , event ) .
WithDoer ( doer ) .
WithPayload ( & api . PullRequestPayload {
Action : api . HookIssueLabelUpdated ,
Action : action ,
Index : issue . Index ,
PullRequest : convert . ToAPIPullRequest ( ctx , issue . PullRequest , nil ) ,
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
Notify ( ctx )
return
}
newNotifyInputFromIssue ( issue , webhook_module . HookEventIssueLabel ) .
permission , _ := access_model . GetUserRepoPermission ( ctx , issue . Repo , issue . Poster )
newNotifyInputFromIssue ( issue , event ) .
WithDoer ( doer ) .
WithPayload ( & api . IssuePayload {
Action : api . HookIssueLabelUpdated ,
Action : action ,
Index : issue . Index ,
Issue : convert . ToAPIIssue ( ctx , issue ) ,
Repository : convert . ToRepo ( ctx , issue . Repo , permission ) ,
@ -305,6 +330,39 @@ func (n *actionsNotifier) PullRequestReview(ctx context.Context, pr *issues_mode
} ) . Notify ( ctx )
}
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 ) {
if ! issue . IsPull {
log . Warn ( "PullRequestReviewRequest: issue is not a pull request: %v" , issue . ID )
return
}
ctx = withMethod ( ctx , "PullRequestReviewRequest" )
permission , _ := access_model . GetUserRepoPermission ( ctx , issue . Repo , doer )
if err := issue . LoadPullRequest ( ctx ) ; err != nil {
log . Error ( "LoadPullRequest failed: %v" , err )
return
}
var action api . HookIssueAction
if isRequest {
action = api . HookIssueReviewRequested
} else {
action = api . HookIssueReviewRequestRemoved
}
newNotifyInputFromIssue ( issue , webhook_module . HookEventPullRequestReviewRequest ) .
WithDoer ( doer ) .
WithPayload ( & api . PullRequestPayload {
Action : action ,
Index : issue . Index ,
PullRequest : convert . ToAPIPullRequest ( ctx , issue . PullRequest , nil ) ,
RequestedReviewer : convert . ToUser ( ctx , reviewer , nil ) ,
Repository : convert . ToRepo ( ctx , issue . Repo , permission ) ,
Sender : convert . ToUser ( ctx , doer , nil ) ,
} ) .
WithPullRequest ( issue . PullRequest ) .
Notify ( ctx )
}
func ( * actionsNotifier ) MergePullRequest ( ctx context . Context , doer * user_model . User , pr * issues_model . PullRequest ) {
ctx = withMethod ( ctx , "MergePullRequest" )