Skip to content

Don't manipulate input params in email notification (#16011) #16033

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 31, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions modules/notification/mail/mail.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ func (m *mailNotifier) NotifyNewIssue(issue *models.Issue, mentions []*models.Us

func (m *mailNotifier) NotifyIssueChangeStatus(doer *models.User, issue *models.Issue, actionComment *models.Comment, isClosed bool) {
var actionType models.ActionType
issue.Content = ""
if issue.IsPull {
if isClosed {
actionType = models.ActionClosePullRequest
Expand Down Expand Up @@ -120,7 +119,6 @@ func (m *mailNotifier) NotifyMergePullRequest(pr *models.PullRequest, doer *mode
log.Error("pr.LoadIssue: %v", err)
return
}
pr.Issue.Content = ""
if err := mailer.MailParticipants(pr.Issue, doer, models.ActionMergePullRequest, nil); err != nil {
log.Error("MailParticipants: %v", err)
}
Expand All @@ -147,7 +145,6 @@ func (m *mailNotifier) NotifyPullRequestPushCommits(doer *models.User, pr *model
if err := comment.LoadPushCommits(); err != nil {
log.Error("comment.LoadPushCommits: %v", err)
}
comment.Content = ""

m.NotifyCreateIssueComment(doer, comment.Issue.Repo, comment.Issue, comment, nil)
}
Expand Down
6 changes: 5 additions & 1 deletion services/mailer/mail_comment.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,16 @@ func mailParticipantsComment(c *models.Comment, opType models.ActionType, issue
for i, u := range mentions {
mentionedIDs[i] = u.ID
}
content := c.Content
if c.Type == models.CommentTypePullPush {
content = ""
}
if err = mailIssueCommentToParticipants(
&mailCommentContext{
Issue: issue,
Doer: c.Poster,
ActionType: opType,
Content: c.Content,
Content: content,
Comment: c,
}, mentionedIDs); err != nil {
log.Error("mailIssueCommentToParticipants: %v", err)
Expand Down
8 changes: 7 additions & 1 deletion services/mailer/mail_issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,12 +158,18 @@ func mailParticipants(issue *models.Issue, doer *models.User, opType models.Acti
for i, u := range mentions {
mentionedIDs[i] = u.ID
}
content := issue.Content
if opType == models.ActionCloseIssue || opType == models.ActionClosePullRequest ||
opType == models.ActionReopenIssue || opType == models.ActionReopenPullRequest ||
opType == models.ActionMergePullRequest {
content = ""
}
if err = mailIssueCommentToParticipants(
&mailCommentContext{
Issue: issue,
Doer: doer,
ActionType: opType,
Content: issue.Content,
Content: content,
Comment: nil,
}, mentionedIDs); err != nil {
log.Error("mailIssueCommentToParticipants: %v", err)
Expand Down