diff --git a/models/issue_comment.go b/models/issue_comment.go index 63f5f6b77..c7e9e7cdf 100644 --- a/models/issue_comment.go +++ b/models/issue_comment.go @@ -539,8 +539,10 @@ func createComment(e *xorm.Session, opts *CreateCommentOptions) (_ *Comment, err return nil, err } - if err = sendCreateCommentAction(e, opts, comment); err != nil { - return nil, err + if !opts.NoAction { + if err = sendCreateCommentAction(e, opts, comment); err != nil { + return nil, err + } } if err = comment.addCrossReferences(e, opts.Doer); err != nil { @@ -816,6 +818,7 @@ type CreateCommentOptions struct { RefCommentID int64 RefAction references.XRefAction RefIsPull bool + NoAction bool } // CreateComment creates comment of issue or commit. diff --git a/models/review.go b/models/review.go index ede2ebd32..22a07f182 100644 --- a/models/review.go +++ b/models/review.go @@ -269,6 +269,13 @@ func SubmitReview(doer *User, issue *Issue, reviewType ReviewType, content strin return nil, nil, err } } else { + if err := review.loadCodeComments(sess); err != nil { + return nil, nil, err + } + if len(review.CodeComments) == 0 && len(strings.TrimSpace(content)) == 0 { + return nil, nil, ContentEmptyErr{} + } + review.Issue = issue review.Content = content review.Type = reviewType @@ -284,16 +291,13 @@ func SubmitReview(doer *User, issue *Issue, reviewType ReviewType, content strin Issue: issue, Repo: issue.Repo, ReviewID: review.ID, + NoAction: true, }) if err != nil || comm == nil { return nil, nil, err } comm.Review = review - - if err := updateIssueCols(sess, review.Issue, "updated_unix"); err != nil { - return nil, nil, err - } return review, comm, sess.Commit() } diff --git a/modules/notification/action/action.go b/modules/notification/action/action.go index 6a81e6af8..05b859530 100644 --- a/modules/notification/action/action.go +++ b/modules/notification/action/action.go @@ -149,17 +149,19 @@ func (a *actionNotifier) NotifyPullRequestReview(pr *models.PullRequest, review } } - actions = append(actions, &models.Action{ - ActUserID: review.Reviewer.ID, - ActUser: review.Reviewer, - Content: fmt.Sprintf("%d|%s", review.Issue.Index, strings.Split(content, "\n")[0]), - OpType: models.ActionCommentIssue, - RepoID: review.Issue.RepoID, - Repo: review.Issue.Repo, - IsPrivate: review.Issue.Repo.IsPrivate, - Comment: comment, - CommentID: comment.ID, - }) + if strings.TrimSpace(comment.Content) != "" { + actions = append(actions, &models.Action{ + ActUserID: review.Reviewer.ID, + ActUser: review.Reviewer, + Content: fmt.Sprintf("%d|%s", review.Issue.Index, strings.Split(content, "\n")[0]), + OpType: models.ActionCommentIssue, + RepoID: review.Issue.RepoID, + Repo: review.Issue.Repo, + IsPrivate: review.Issue.Repo.IsPrivate, + Comment: comment, + CommentID: comment.ID, + }) + } if err := models.NotifyWatchersActions(actions); err != nil { log.Error("notify watchers '%d/%d': %v", review.Reviewer.ID, review.Issue.RepoID, err)