mirror of
https://gitcode.com/gitea/gitea.git
synced 2025-05-31 07:08:06 +08:00
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
This commit is contained in:

committed by
techknowlogick

parent
5d3e351864
commit
944d904980
@ -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
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user