Skip to content

Commit 0e063de

Browse files
committed
remove duplicated actions
1 parent 5067294 commit 0e063de

File tree

3 files changed

+26
-17
lines changed

3 files changed

+26
-17
lines changed

models/issue_comment.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -539,8 +539,10 @@ func createComment(e *xorm.Session, opts *CreateCommentOptions) (_ *Comment, err
539539
return nil, err
540540
}
541541

542-
if err = sendCreateCommentAction(e, opts, comment); err != nil {
543-
return nil, err
542+
if !opts.NoAction {
543+
if err = sendCreateCommentAction(e, opts, comment); err != nil {
544+
return nil, err
545+
}
544546
}
545547

546548
if err = comment.addCrossReferences(e, opts.Doer); err != nil {
@@ -816,6 +818,7 @@ type CreateCommentOptions struct {
816818
RefCommentID int64
817819
RefAction references.XRefAction
818820
RefIsPull bool
821+
NoAction bool
819822
}
820823

821824
// CreateComment creates comment of issue or commit.

models/review.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,13 @@ func SubmitReview(doer *User, issue *Issue, reviewType ReviewType, content strin
269269
return nil, nil, err
270270
}
271271
} else {
272+
if err := review.loadCodeComments(sess); err != nil {
273+
return nil, nil, err
274+
}
275+
if len(review.CodeComments) == 0 && len(strings.TrimSpace(content)) == 0 {
276+
return nil, nil, ContentEmptyErr{}
277+
}
278+
272279
review.Issue = issue
273280
review.Content = content
274281
review.Type = reviewType
@@ -284,16 +291,13 @@ func SubmitReview(doer *User, issue *Issue, reviewType ReviewType, content strin
284291
Issue: issue,
285292
Repo: issue.Repo,
286293
ReviewID: review.ID,
294+
NoAction: true,
287295
})
288296
if err != nil || comm == nil {
289297
return nil, nil, err
290298
}
291299

292300
comm.Review = review
293-
294-
if err := updateIssueCols(sess, review.Issue, "updated_unix"); err != nil {
295-
return nil, nil, err
296-
}
297301
return review, comm, sess.Commit()
298302
}
299303

modules/notification/action/action.go

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -149,17 +149,19 @@ func (a *actionNotifier) NotifyPullRequestReview(pr *models.PullRequest, review
149149
}
150150
}
151151

152-
actions = append(actions, &models.Action{
153-
ActUserID: review.Reviewer.ID,
154-
ActUser: review.Reviewer,
155-
Content: fmt.Sprintf("%d|%s", review.Issue.Index, strings.Split(content, "\n")[0]),
156-
OpType: models.ActionCommentIssue,
157-
RepoID: review.Issue.RepoID,
158-
Repo: review.Issue.Repo,
159-
IsPrivate: review.Issue.Repo.IsPrivate,
160-
Comment: comment,
161-
CommentID: comment.ID,
162-
})
152+
if strings.TrimSpace(comment.Content) != "" {
153+
actions = append(actions, &models.Action{
154+
ActUserID: review.Reviewer.ID,
155+
ActUser: review.Reviewer,
156+
Content: fmt.Sprintf("%d|%s", review.Issue.Index, strings.Split(content, "\n")[0]),
157+
OpType: models.ActionCommentIssue,
158+
RepoID: review.Issue.RepoID,
159+
Repo: review.Issue.Repo,
160+
IsPrivate: review.Issue.Repo.IsPrivate,
161+
Comment: comment,
162+
CommentID: comment.ID,
163+
})
164+
}
163165

164166
if err := models.NotifyWatchersActions(actions); err != nil {
165167
log.Error("notify watchers '%d/%d': %v", review.Reviewer.ID, review.Issue.RepoID, err)

0 commit comments

Comments
 (0)