@ -224,37 +224,88 @@ func (n *actionsNotifier) CreateIssueComment(ctx context.Context, doer *user_mod
) {
) {
ctx = withMethod ( ctx , "CreateIssueComment" )
ctx = withMethod ( ctx , "CreateIssueComment" )
permission , _ := access_model . GetUserRepoPermission ( ctx , repo , doer )
if issue . IsPull {
if issue . IsPull {
if err := issue . LoadPullRequest ( ctx ) ; err != nil {
notifyIssueCommentChange ( ctx , doer , comment , "" , webhook_module . HookEventPullRequestComment , api . HookIssueCommentCreated )
return
}
notifyIssueCommentChange ( ctx , doer , comment , "" , webhook_module . HookEventIssueComment , api . HookIssueCommentCreated )
}
func ( n * actionsNotifier ) UpdateComment ( ctx context . Context , doer * user_model . User , c * issues_model . Comment , oldContent string ) {
ctx = withMethod ( ctx , "UpdateComment" )
if err := c . LoadIssue ( ctx ) ; err != nil {
log . Error ( "LoadIssue: %v" , err )
return
}
if c . Issue . IsPull {
notifyIssueCommentChange ( ctx , doer , c , oldContent , webhook_module . HookEventPullRequestComment , api . HookIssueCommentEdited )
return
}
notifyIssueCommentChange ( ctx , doer , c , oldContent , webhook_module . HookEventIssueComment , api . HookIssueCommentEdited )
}
func ( n * actionsNotifier ) DeleteComment ( ctx context . Context , doer * user_model . User , comment * issues_model . Comment ) {
ctx = withMethod ( ctx , "DeleteComment" )
if err := comment . LoadIssue ( ctx ) ; err != nil {
log . Error ( "LoadIssue: %v" , err )
return
}
if comment . Issue . IsPull {
notifyIssueCommentChange ( ctx , doer , comment , "" , webhook_module . HookEventPullRequestComment , api . HookIssueCommentDeleted )
return
}
notifyIssueCommentChange ( ctx , doer , comment , "" , webhook_module . HookEventIssueComment , api . HookIssueCommentDeleted )
}
func notifyIssueCommentChange ( ctx context . Context , doer * user_model . User , comment * issues_model . Comment , oldContent string , event webhook_module . HookEventType , action api . HookIssueCommentAction ) {
if err := comment . LoadIssue ( ctx ) ; err != nil {
log . Error ( "LoadIssue: %v" , err )
return
}
if err := comment . Issue . LoadAttributes ( ctx ) ; err != nil {
log . Error ( "LoadAttributes: %v" , err )
return
}
permission , _ := access_model . GetUserRepoPermission ( ctx , comment . Issue . Repo , doer )
payload := & api . IssueCommentPayload {
Action : action ,
Issue : convert . ToAPIIssue ( ctx , comment . Issue ) ,
Comment : convert . ToAPIComment ( ctx , comment . Issue . Repo , comment ) ,
Repository : convert . ToRepo ( ctx , comment . Issue . Repo , permission ) ,
Sender : convert . ToUser ( ctx , doer , nil ) ,
IsPull : comment . Issue . IsPull ,
}
if action == api . HookIssueCommentEdited {
payload . Changes = & api . ChangesPayload {
Body : & api . ChangesFromPayload {
From : oldContent ,
} ,
}
}
if comment . Issue . IsPull {
if err := comment . Issue . LoadPullRequest ( ctx ) ; err != nil {
log . Error ( "LoadPullRequest: %v" , err )
log . Error ( "LoadPullRequest: %v" , err )
return
return
}
}
newNotifyInputFromIssue ( issue , webhook_module . HookEventPullRequestComment ) .
newNotifyInputFromIssue ( comment . Issue , ev ent) .
WithDoer ( doer ) .
WithDoer ( doer ) .
WithPayload ( & api . IssueCommentPayload {
WithPayload ( payload ) .
Action : api . HookIssueCommentCreated ,
WithPullRequest ( comment . Issue . PullRequest ) .
Issue : convert . ToAPIIssue ( ctx , issue ) ,
Comment : convert . ToAPIComment ( ctx , repo , comment ) ,
Repository : convert . ToRepo ( ctx , repo , permission ) ,
Sender : convert . ToUser ( ctx , doer , nil ) ,
IsPull : true ,
} ) .
WithPullRequest ( issue . PullRequest ) .
Notify ( ctx )
Notify ( ctx )
return
return
}
}
newNotifyInputFromIssue ( issue , webhook_module . HookEventIssueComment ) .
newNotifyInputFromIssue ( comment . Issue , event ) .
WithDoer ( doer ) .
WithDoer ( doer ) .
WithPayload ( & api . IssueCommentPayload {
WithPayload ( payload ) .
Action : api . HookIssueCommentCreated ,
Issue : convert . ToAPIIssue ( ctx , issue ) ,
Comment : convert . ToAPIComment ( ctx , repo , comment ) ,
Repository : convert . ToRepo ( ctx , repo , permission ) ,
Sender : convert . ToUser ( ctx , doer , nil ) ,
IsPull : false ,
} ) .
Notify ( ctx )
Notify ( ctx )
}
}
@ -496,7 +547,6 @@ func (n *actionsNotifier) DeleteRef(ctx context.Context, pusher *user_model.User
apiRepo := convert . ToRepo ( ctx , repo , access_model . Permission { AccessMode : perm_model . AccessModeNone } )
apiRepo := convert . ToRepo ( ctx , repo , access_model . Permission { AccessMode : perm_model . AccessModeNone } )
newNotifyInput ( repo , pusher , webhook_module . HookEventDelete ) .
newNotifyInput ( repo , pusher , webhook_module . HookEventDelete ) .
WithRef ( refFullName . ShortName ( ) ) . // FIXME: should we use a full ref name
WithPayload ( & api . DeletePayload {
WithPayload ( & api . DeletePayload {
Ref : refFullName . ShortName ( ) ,
Ref : refFullName . ShortName ( ) ,
RefType : refFullName . RefType ( ) ,
RefType : refFullName . RefType ( ) ,