Skip to content

Commit d79c8bc

Browse files
authored
Don't manipulate input params in email notification (#16011)
1 parent d8c99c6 commit d79c8bc

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

modules/notification/mail/mail.go

Lines changed: 0 additions & 4 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
@@ -124,7 +123,6 @@ func (m *mailNotifier) NotifyMergePullRequest(pr *models.PullRequest, doer *mode
124123
log.Error("pr.LoadIssue: %v", err)
125124
return
126125
}
127-
pr.Issue.Content = ""
128126
if err := mailer.MailParticipants(pr.Issue, doer, models.ActionMergePullRequest, nil); err != nil {
129127
log.Error("MailParticipants: %v", err)
130128
}
@@ -151,8 +149,6 @@ func (m *mailNotifier) NotifyPullRequestPushCommits(doer *models.User, pr *model
151149
if err := comment.LoadPushCommits(); err != nil {
152150
log.Error("comment.LoadPushCommits: %v", err)
153151
}
154-
comment.Content = ""
155-
156152
m.NotifyCreateIssueComment(doer, comment.Issue.Repo, comment.Issue, comment, nil)
157153
}
158154

services/mailer/mail_comment.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,16 @@ import (
1111

1212
// MailParticipantsComment sends new comment emails to repository watchers and mentioned people.
1313
func MailParticipantsComment(c *models.Comment, opType models.ActionType, issue *models.Issue, mentions []*models.User) error {
14+
content := c.Content
15+
if c.Type == models.CommentTypePullPush {
16+
content = ""
17+
}
1418
if err := mailIssueCommentToParticipants(
1519
&mailCommentContext{
1620
Issue: issue,
1721
Doer: c.Poster,
1822
ActionType: opType,
19-
Content: c.Content,
23+
Content: content,
2024
Comment: c,
2125
}, mentions); err != nil {
2226
log.Error("mailIssueCommentToParticipants: %v", err)

services/mailer/mail_issue.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,12 +161,18 @@ func mailIssueCommentBatch(ctx *mailCommentContext, users []*models.User, visite
161161
// MailParticipants sends new issue thread created emails to repository watchers
162162
// and mentioned people.
163163
func MailParticipants(issue *models.Issue, doer *models.User, opType models.ActionType, mentions []*models.User) error {
164+
content := issue.Content
165+
if opType == models.ActionCloseIssue || opType == models.ActionClosePullRequest ||
166+
opType == models.ActionReopenIssue || opType == models.ActionReopenPullRequest ||
167+
opType == models.ActionMergePullRequest {
168+
content = ""
169+
}
164170
if err := mailIssueCommentToParticipants(
165171
&mailCommentContext{
166172
Issue: issue,
167173
Doer: doer,
168174
ActionType: opType,
169-
Content: issue.Content,
175+
Content: content,
170176
Comment: nil,
171177
}, mentions); err != nil {
172178
log.Error("mailIssueCommentToParticipants: %v", err)

0 commit comments

Comments
 (0)