Browse Source

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

Backport #16011
mj-v1.14.3
Jimmy Praet 1 year ago
committed by GitHub
parent
commit
8007602b40
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      modules/notification/mail/mail.go
  2. 6
      services/mailer/mail_comment.go
  3. 8
      services/mailer/mail_issue.go

3
modules/notification/mail/mail.go

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

6
services/mailer/mail_comment.go

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

8
services/mailer/mail_issue.go

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

Loading…
Cancel
Save