Skip to content

Commit b39fab4

Browse files
mrsdizzielafriks
authored andcommitted
Some more e-mail notification fixes (#9596)
* Some more e-mail notification fixes A few more small e-mail notification fixes/changes * Style footer of notification email to be smaller * Include text for when pull request is merged * Don't include original body of issue or PR when merging/closing by setting issue.Content to "" in these cases * Set Re: prefix and meessage-ID headers based on actName instead of checking for a comment. This fixes a bug where certain actions that didn't have a comment were setting Message-ID instead of In-Reply-To which caused some mail programs not to show those messages as they would have had the same Message-ID as a previous message. Also fixes the case where a final comment and closing message would have been displayed out of order if you didn't have a copy of the original issue/pr cretion message. * Update other template footers for consistency
1 parent 134e3fd commit b39fab4

File tree

5 files changed

+39
-20
lines changed

5 files changed

+39
-20
lines changed

modules/notification/mail/mail.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ func (m *mailNotifier) NotifyNewIssue(issue *models.Issue) {
5353

5454
func (m *mailNotifier) NotifyIssueChangeStatus(doer *models.User, issue *models.Issue, actionComment *models.Comment, isClosed bool) {
5555
var actionType models.ActionType
56+
issue.Content = ""
5657
if issue.IsPull {
5758
if isClosed {
5859
actionType = models.ActionClosePullRequest
@@ -105,7 +106,7 @@ func (m *mailNotifier) NotifyMergePullRequest(pr *models.PullRequest, doer *mode
105106
log.Error("pr.LoadIssue: %v", err)
106107
return
107108
}
108-
109+
pr.Issue.Content = ""
109110
if err := mailer.MailParticipants(pr.Issue, doer, models.ActionMergePullRequest); err != nil {
110111
log.Error("MailParticipants: %v", err)
111112
}

services/mailer/mail.go

+6-4
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,6 @@ func composeIssueCommentMessages(ctx *mailCommentContext, tos []string, fromMent
177177

178178
commentType := models.CommentTypeComment
179179
if ctx.Comment != nil {
180-
prefix = "Re: "
181180
commentType = ctx.Comment.Type
182181
link = ctx.Issue.HTMLURL() + "#" + ctx.Comment.HashTag()
183182
} else {
@@ -189,13 +188,16 @@ func composeIssueCommentMessages(ctx *mailCommentContext, tos []string, fromMent
189188
reviewType = ctx.Comment.Review.Type
190189
}
191190

192-
fallback = prefix + fallbackMailSubject(ctx.Issue)
193-
194191
// This is the body of the new issue or comment, not the mail body
195192
body := string(markup.RenderByType(markdown.MarkupName, []byte(ctx.Content), ctx.Issue.Repo.HTMLURL(), ctx.Issue.Repo.ComposeMetas()))
196193

197194
actType, actName, tplName := actionToTemplate(ctx.Issue, ctx.ActionType, commentType, reviewType)
198195

196+
if actName != "new" {
197+
prefix = "Re: "
198+
}
199+
fallback = prefix + fallbackMailSubject(ctx.Issue)
200+
199201
if ctx.Comment != nil && ctx.Comment.Review != nil {
200202
reviewComments = make([]*models.Comment, 0, 10)
201203
for _, lines := range ctx.Comment.Review.CodeComments {
@@ -247,7 +249,7 @@ func composeIssueCommentMessages(ctx *mailCommentContext, tos []string, fromMent
247249
msg.Info = fmt.Sprintf("Subject: %s, %s", subject, info)
248250

249251
// Set Message-ID on first message so replies know what to reference
250-
if ctx.Comment == nil {
252+
if actName == "new" {
251253
msg.SetHeader("Message-ID", "<"+ctx.Issue.ReplyReference()+">")
252254
} else {
253255
msg.SetHeader("In-Reply-To", "<"+ctx.Issue.ReplyReference()+">")

templates/mail/issue/assigned.tmpl

+10-6
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
11
<!DOCTYPE html>
22
<html>
33
<head>
4+
<style>
5+
.footer { font-size:small; color:#666;}
6+
</style>
47
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
58
<title>{{.Subject}}</title>
69
</head>
710

811
<body>
912
<p>@{{.Doer.Name}} assigned you to the {{if .IsPull}}pull request{{else}}issue{{end}} <a href="{{.Link}}">#{{.Issue.Index}}</a> in repository {{.Repo}}.</p>
10-
<p>
11-
---
12-
<br>
13-
<a href="{{.Link}}">View it on {{AppName}}</a>.
14-
</p>
15-
13+
<div class="footer">
14+
<p>
15+
---
16+
<br>
17+
<a href="{{.Link}}">View it on {{AppName}}</a>.
18+
</p>
19+
</div>
1620
</body>
1721
</html>

templates/mail/issue/default.tmpl

+11-4
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,15 @@
33
<head>
44
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
55
<title>{{.Subject}}</title>
6-
{{if .ReviewComments}}
6+
77
<style>
8-
.review { padding-left: 1em; margin: 1em 0; }
9-
.review > pre { padding: 1em; border-left: 1px solid grey; }
8+
.footer { font-size:small; color:#666;}
9+
{{if .ReviewComments}}
10+
.review { padding-left: 1em; margin: 1em 0; }
11+
.review > pre { padding: 1em; border-left: 1px solid grey; }
12+
{{end}}
1013
</style>
11-
{{end}}
14+
1215
</head>
1316

1417
<body>
@@ -18,6 +21,8 @@
1821
Closed #{{.Issue.Index}}.
1922
{{else if eq .ActionName "reopen"}}
2023
Reopened #{{.Issue.Index}}.
24+
{{else if eq .ActionName "merge"}}
25+
Merged #{{.Issue.Index}} into {{.Issue.PullRequest.BaseBranch}}.
2126
{{else if eq .ActionName "approve"}}
2227
<b>@{{.Doer.Name}}</b> approved this pull request.
2328
{{else if eq .ActionName "reject"}}
@@ -42,10 +47,12 @@
4247
</div>
4348
{{end -}}
4449
</p>
50+
<div class="footer">
4551
<p>
4652
---
4753
<br>
4854
<a href="{{.Link}}">View it on {{AppName}}</a>.
4955
</p>
56+
</div>
5057
</body>
5158
</html>
+10-5
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
11
<!DOCTYPE html>
22
<html>
33
<head>
4+
<style>
5+
.footer { font-size:small; color:#666;}
6+
</style>
47
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
58
<title>{{.Subject}}</title>
69
</head>
710

811
<body>
912
<p>You have been added as a collaborator of repository: <code>{{.RepoName}}</code></p>
10-
<p>
11-
---
12-
<br>
13-
<a href="{{.Link}}">View it on Gitea</a>.
14-
</p>
13+
<div class="footer">
14+
<p>
15+
---
16+
<br>
17+
<a href="{{.Link}}">View it on {{AppName}}</a>.
18+
</p>
19+
</div>
1520
</body>
1621
</html>

0 commit comments

Comments
 (0)