@@ -46,15 +46,22 @@ func DeleteWikiPage(ctx context.Context, doer *user_model.User, repo *repo_model
46
46
}
47
47
}
48
48
49
- // CreateIssueComment notifies issue comment related message to notifiers
50
- func CreateIssueComment (ctx context.Context , doer * user_model.User , repo * repo_model.Repository ,
51
- issue * issues_model.Issue , comment * issues_model.Comment , mentions []* user_model.User ,
52
- ) {
49
+ func shouldSendCommentChangeNotification (ctx context.Context , comment * issues_model.Comment ) bool {
53
50
if err := comment .LoadReview (ctx ); err != nil {
54
51
log .Error ("LoadReview: %v" , err )
55
- return
52
+ return false
56
53
} else if comment .Review != nil && comment .Review .Type == issues_model .ReviewTypePending {
57
54
// Pending review comments updating should not triggered
55
+ return false
56
+ }
57
+ return true
58
+ }
59
+
60
+ // CreateIssueComment notifies issue comment related message to notifiers
61
+ func CreateIssueComment (ctx context.Context , doer * user_model.User , repo * repo_model.Repository ,
62
+ issue * issues_model.Issue , comment * issues_model.Comment , mentions []* user_model.User ,
63
+ ) {
64
+ if ! shouldSendCommentChangeNotification (ctx , comment ) {
58
65
return
59
66
}
60
67
@@ -164,11 +171,7 @@ func PullReviewDismiss(ctx context.Context, doer *user_model.User, review *issue
164
171
165
172
// UpdateComment notifies update comment to notifiers
166
173
func UpdateComment (ctx context.Context , doer * user_model.User , c * issues_model.Comment , oldContent string ) {
167
- if err := c .LoadReview (ctx ); err != nil {
168
- log .Error ("LoadReview: %v" , err )
169
- return
170
- } else if c .Review != nil && c .Review .Type == issues_model .ReviewTypePending {
171
- // Pending review comments updating should not triggered
174
+ if ! shouldSendCommentChangeNotification (ctx , c ) {
172
175
return
173
176
}
174
177
@@ -179,11 +182,7 @@ func UpdateComment(ctx context.Context, doer *user_model.User, c *issues_model.C
179
182
180
183
// DeleteComment notifies delete comment to notifiers
181
184
func DeleteComment (ctx context.Context , doer * user_model.User , c * issues_model.Comment ) {
182
- if err := c .LoadReview (ctx ); err != nil {
183
- log .Error ("LoadReview: %v" , err )
184
- return
185
- } else if c .Review != nil && c .Review .Type == issues_model .ReviewTypePending {
186
- // Pending review comments updating should not triggered
185
+ if ! shouldSendCommentChangeNotification (ctx , c ) {
187
186
return
188
187
}
189
188
0 commit comments