diff options
author | mrsdizzie <info@mrsdizzie.com> | 2019-12-22 03:29:26 -0500 |
---|---|---|
committer | zeripath <art27@cantab.net> | 2019-12-22 08:29:26 +0000 |
commit | 1df701fd1abbcee93dfcd3cdb114a0f35cb6be45 (patch) | |
tree | 70b1f1a47be30eb83ae89a6ba444bcf48357f303 /modules | |
parent | 875d6b2f8e52a362e47118393bcd47026852db8c (diff) | |
download | gitea-1df701fd1abbcee93dfcd3cdb114a0f35cb6be45.tar.gz gitea-1df701fd1abbcee93dfcd3cdb114a0f35cb6be45.zip |
Add ActionCommentPull action (#9456)
* Add ActionCommentPull action
Adds ActionCommentPull action to distinguish between a comment on an
issue and on a pull request
* Update modules/notification/action/action.go
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Diffstat (limited to 'modules')
-rw-r--r-- | modules/notification/action/action.go | 10 | ||||
-rw-r--r-- | modules/notification/mail/mail.go | 2 | ||||
-rw-r--r-- | modules/templates/helper.go | 2 |
3 files changed, 9 insertions, 5 deletions
diff --git a/modules/notification/action/action.go b/modules/notification/action/action.go index 7441de638a..00f049d432 100644 --- a/modules/notification/action/action.go +++ b/modules/notification/action/action.go @@ -90,7 +90,6 @@ func (a *actionNotifier) NotifyIssueChangeStatus(doer *models.User, issue *model func (a *actionNotifier) NotifyCreateIssueComment(doer *models.User, repo *models.Repository, issue *models.Issue, comment *models.Comment) { act := &models.Action{ - OpType: models.ActionCommentIssue, ActUserID: doer.ID, ActUser: doer, Content: fmt.Sprintf("%d|%s", issue.Index, comment.Content), @@ -100,6 +99,11 @@ func (a *actionNotifier) NotifyCreateIssueComment(doer *models.User, repo *model CommentID: comment.ID, IsPrivate: issue.Repo.IsPrivate, } + if issue.IsPull { + act.OpType = models.ActionCommentPull + } else { + act.OpType = models.ActionCommentIssue + } // Notify watchers for whatever action comes in, ignore if no action type. if err := models.NotifyWatchers(act); err != nil { @@ -208,7 +212,7 @@ func (a *actionNotifier) NotifyPullRequestReview(pr *models.PullRequest, review ActUserID: review.Reviewer.ID, ActUser: review.Reviewer, Content: fmt.Sprintf("%d|%s", review.Issue.Index, strings.Split(comm.Content, "\n")[0]), - OpType: models.ActionCommentIssue, + OpType: models.ActionCommentPull, RepoID: review.Issue.RepoID, Repo: review.Issue.Repo, IsPrivate: review.Issue.Repo.IsPrivate, @@ -237,7 +241,7 @@ func (a *actionNotifier) NotifyPullRequestReview(pr *models.PullRequest, review case models.ReviewTypeReject: action.OpType = models.ActionRejectPullRequest default: - action.OpType = models.ActionCommentIssue + action.OpType = models.ActionCommentPull } actions = append(actions, action) diff --git a/modules/notification/mail/mail.go b/modules/notification/mail/mail.go index e9a6ad7af2..5148434dca 100644 --- a/modules/notification/mail/mail.go +++ b/modules/notification/mail/mail.go @@ -85,7 +85,7 @@ func (m *mailNotifier) NotifyPullRequestReview(pr *models.PullRequest, r *models } else if comment.Type == models.CommentTypeReopen { act = models.ActionReopenIssue } else if comment.Type == models.CommentTypeComment { - act = models.ActionCommentIssue + act = models.ActionCommentPull } if err := mailer.MailParticipantsComment(comment, act, pr.Issue); err != nil { log.Error("MailParticipantsComment: %v", err) diff --git a/modules/templates/helper.go b/modules/templates/helper.go index 8b5497a1c9..e0cdcbf60a 100644 --- a/modules/templates/helper.go +++ b/modules/templates/helper.go @@ -548,7 +548,7 @@ func ActionIcon(opType models.ActionType) string { return "issue-opened" case models.ActionCreatePullRequest: return "git-pull-request" - case models.ActionCommentIssue: + case models.ActionCommentIssue, models.ActionCommentPull: return "comment-discussion" case models.ActionMergePullRequest: return "git-merge" |