Skip to content

Commit 8007602

Browse files
authored
Don't manipulate input params in email notification (#16011) (#16033)
Backport #16011
1 parent 3a79f11 commit 8007602

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

modules/notification/mail/mail.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ func (m *mailNotifier) NotifyNewIssue(issue *models.Issue, mentions []*models.Us
5454

5555
func (m *mailNotifier) NotifyIssueChangeStatus(doer *models.User, issue *models.Issue, actionComment *models.Comment, isClosed bool) {
5656
var actionType models.ActionType
57-
issue.Content = ""
5857
if issue.IsPull {
5958
if isClosed {
6059
actionType = models.ActionClosePullRequest
@@ -120,7 +119,6 @@ func (m *mailNotifier) NotifyMergePullRequest(pr *models.PullRequest, doer *mode
120119
log.Error("pr.LoadIssue: %v", err)
121120
return
122121
}
123-
pr.Issue.Content = ""
124122
if err := mailer.MailParticipants(pr.Issue, doer, models.ActionMergePullRequest, nil); err != nil {
125123
log.Error("MailParticipants: %v", err)
126124
}
@@ -147,7 +145,6 @@ func (m *mailNotifier) NotifyPullRequestPushCommits(doer *models.User, pr *model
147145
if err := comment.LoadPushCommits(); err != nil {
148146
log.Error("comment.LoadPushCommits: %v", err)
149147
}
150-
comment.Content = ""
151148

152149
m.NotifyCreateIssueComment(doer, comment.Issue.Repo, comment.Issue, comment, nil)
153150
}

services/mailer/mail_comment.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,16 @@ func mailParticipantsComment(c *models.Comment, opType models.ActionType, issue
2020
for i, u := range mentions {
2121
mentionedIDs[i] = u.ID
2222
}
23+
content := c.Content
24+
if c.Type == models.CommentTypePullPush {
25+
content = ""
26+
}
2327
if err = mailIssueCommentToParticipants(
2428
&mailCommentContext{
2529
Issue: issue,
2630
Doer: c.Poster,
2731
ActionType: opType,
28-
Content: c.Content,
32+
Content: content,
2933
Comment: c,
3034
}, mentionedIDs); err != nil {
3135
log.Error("mailIssueCommentToParticipants: %v", err)

services/mailer/mail_issue.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,12 +158,18 @@ func mailParticipants(issue *models.Issue, doer *models.User, opType models.Acti
158158
for i, u := range mentions {
159159
mentionedIDs[i] = u.ID
160160
}
161+
content := issue.Content
162+
if opType == models.ActionCloseIssue || opType == models.ActionClosePullRequest ||
163+
opType == models.ActionReopenIssue || opType == models.ActionReopenPullRequest ||
164+
opType == models.ActionMergePullRequest {
165+
content = ""
166+
}
161167
if err = mailIssueCommentToParticipants(
162168
&mailCommentContext{
163169
Issue: issue,
164170
Doer: doer,
165171
ActionType: opType,
166-
Content: issue.Content,
172+
Content: content,
167173
Comment: nil,
168174
}, mentionedIDs); err != nil {
169175
log.Error("mailIssueCommentToParticipants: %v", err)

0 commit comments

Comments
 (0)