remove duplicated actions

This commit is contained in:
Lunny Xiao 2019-11-13 20:54:12 +08:00
parent 5067294f32
commit 0e063de211
No known key found for this signature in database
GPG Key ID: C3B7C91B632F738A
3 changed files with 26 additions and 17 deletions

View File

@ -539,9 +539,11 @@ func createComment(e *xorm.Session, opts *CreateCommentOptions) (_ *Comment, err
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 {
return nil, err
@ -816,6 +818,7 @@ type CreateCommentOptions struct {
RefCommentID int64
RefAction references.XRefAction
RefIsPull bool
NoAction bool
}
// CreateComment creates comment of issue or commit.

View File

@ -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()
}

View File

@ -149,6 +149,7 @@ func (a *actionNotifier) NotifyPullRequestReview(pr *models.PullRequest, review
}
}
if strings.TrimSpace(comment.Content) != "" {
actions = append(actions, &models.Action{
ActUserID: review.Reviewer.ID,
ActUser: review.Reviewer,
@ -160,6 +161,7 @@ func (a *actionNotifier) NotifyPullRequestReview(pr *models.PullRequest, review
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)