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
This commit is contained in:
mrsdizzie 2020-01-03 12:13:22 -05:00 committed by Lauris BH
parent 134e3fdf3d
commit b39fab41c8
5 changed files with 39 additions and 20 deletions

View file

@ -177,7 +177,6 @@ func composeIssueCommentMessages(ctx *mailCommentContext, tos []string, fromMent
commentType := models.CommentTypeComment
if ctx.Comment != nil {
prefix = "Re: "
commentType = ctx.Comment.Type
link = ctx.Issue.HTMLURL() + "#" + ctx.Comment.HashTag()
} else {
@ -189,13 +188,16 @@ func composeIssueCommentMessages(ctx *mailCommentContext, tos []string, fromMent
reviewType = ctx.Comment.Review.Type
}
fallback = prefix + fallbackMailSubject(ctx.Issue)
// This is the body of the new issue or comment, not the mail body
body := string(markup.RenderByType(markdown.MarkupName, []byte(ctx.Content), ctx.Issue.Repo.HTMLURL(), ctx.Issue.Repo.ComposeMetas()))
actType, actName, tplName := actionToTemplate(ctx.Issue, ctx.ActionType, commentType, reviewType)
if actName != "new" {
prefix = "Re: "
}
fallback = prefix + fallbackMailSubject(ctx.Issue)
if ctx.Comment != nil && ctx.Comment.Review != nil {
reviewComments = make([]*models.Comment, 0, 10)
for _, lines := range ctx.Comment.Review.CodeComments {
@ -247,7 +249,7 @@ func composeIssueCommentMessages(ctx *mailCommentContext, tos []string, fromMent
msg.Info = fmt.Sprintf("Subject: %s, %s", subject, info)
// Set Message-ID on first message so replies know what to reference
if ctx.Comment == nil {
if actName == "new" {
msg.SetHeader("Message-ID", "<"+ctx.Issue.ReplyReference()+">")
} else {
msg.SetHeader("In-Reply-To", "<"+ctx.Issue.ReplyReference()+">")