aboutsummaryrefslogtreecommitdiffstats
path: root/services/mailer/mail.go
diff options
context:
space:
mode:
Diffstat (limited to 'services/mailer/mail.go')
-rw-r--r--services/mailer/mail.go27
1 files changed, 20 insertions, 7 deletions
diff --git a/services/mailer/mail.go b/services/mailer/mail.go
index 721f6eb49b..bd8f059c5e 100644
--- a/services/mailer/mail.go
+++ b/services/mailer/mail.go
@@ -305,13 +305,10 @@ func composeIssueCommentMessages(ctx *mailCommentContext, lang string, recipient
msg := NewMessageFrom([]string{recipient.Email}, ctx.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 actName == "new" {
- msg.SetHeader("Message-ID", "<"+ctx.Issue.ReplyReference()+">")
- } else {
- msg.SetHeader("In-Reply-To", "<"+ctx.Issue.ReplyReference()+">")
- msg.SetHeader("References", "<"+ctx.Issue.ReplyReference()+">")
- }
+ msg.SetHeader("Message-ID", "<"+createReference(ctx.Issue, ctx.Comment)+">")
+ reference := createReference(ctx.Issue, nil)
+ msg.SetHeader("In-Reply-To", "<"+reference+">")
+ msg.SetHeader("References", "<"+reference+">")
for key, value := range generateAdditionalHeaders(ctx, actType, recipient) {
msg.SetHeader(key, value)
@@ -323,6 +320,22 @@ func composeIssueCommentMessages(ctx *mailCommentContext, lang string, recipient
return msgs, nil
}
+func createReference(issue *models.Issue, comment *models.Comment) string {
+ var path string
+ if issue.IsPull {
+ path = "pulls"
+ } else {
+ path = "issues"
+ }
+
+ var extra string
+ if comment != nil {
+ extra = fmt.Sprintf("/comment/%d", comment.ID)
+ }
+
+ return fmt.Sprintf("%s/%s/%d%s@%s", issue.Repo.FullName(), path, issue.Index, extra, setting.Domain)
+}
+
func generateAdditionalHeaders(ctx *mailCommentContext, reason string, recipient *models.User) map[string]string {
repo := ctx.Issue.Repo