aboutsummaryrefslogtreecommitdiffstats
path: root/models/mail.go
diff options
context:
space:
mode:
authormrsdizzie <info@mrsdizzie.com>2019-07-17 15:02:42 -0400
committertechknowlogick <techknowlogick@gitea.io>2019-07-17 15:02:42 -0400
commit944d904980f7b161a96d5208d59c20004429d126 (patch)
tree1370357a8e7c22f7a08d04c9c5bfc5146a1778ae /models/mail.go
parent5d3e3518645d707d99c6ea244a195b7240782e74 (diff)
downloadgitea-944d904980f7b161a96d5208d59c20004429d126.tar.gz
gitea-944d904980f7b161a96d5208d59c20004429d126.zip
Include thread related headers in issue/coment mail (#7484)
* Include thread related headers in issue/coment mail Make it so mail programs will group comments from an issue into the same thread by setting Message-ID on initial issue and then using In-Reply-To and References headers to reference that later on. * Add tests * more tests * fix typo
Diffstat (limited to 'models/mail.go')
-rw-r--r--models/mail.go17
1 files changed, 16 insertions, 1 deletions
diff --git a/models/mail.go b/models/mail.go
index 2bb07607a4..cd4e4bc804 100644
--- a/models/mail.go
+++ b/models/mail.go
@@ -156,7 +156,13 @@ func composeTplData(subject, body, link string) map[string]interface{} {
}
func composeIssueCommentMessage(issue *Issue, doer *User, content string, comment *Comment, tplName base.TplName, tos []string, info string) *mailer.Message {
- subject := issue.mailSubject()
+ var subject string
+ if comment != nil {
+ subject = "Re: " + issue.mailSubject()
+ } else {
+ subject = issue.mailSubject()
+ }
+
err := issue.LoadRepo()
if err != nil {
log.Error("LoadRepo: %v", err)
@@ -179,6 +185,15 @@ func composeIssueCommentMessage(issue *Issue, doer *User, content string, commen
msg := mailer.NewMessageFrom(tos, doer.DisplayName(), setting.MailService.FromEmail, subject, mailBody.String())
msg.Info = fmt.Sprintf("Subject: %s, %s", subject, info)
+
+ // Set Message-ID on first message so replies know what to reference
+ if comment == nil {
+ msg.SetHeader("Message-ID", "<"+issue.ReplyReference()+">")
+ } else {
+ msg.SetHeader("In-Reply-To", "<"+issue.ReplyReference()+">")
+ msg.SetHeader("References", "<"+issue.ReplyReference()+">")
+ }
+
return msg
}