Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include thread related headers in issue/coment mail #7484

Merged
merged 6 commits into from
Jul 17, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions models/issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,18 @@ func (issue *Issue) sendLabelUpdatedWebhook(doer *User) {
}
}

// ReplyReference returns tokenized address to use for email reply headers
func (issue *Issue) ReplyReference() string {
var path string
if issue.IsPull {
path = "pulls"
} else {
path = "issues"
}

return fmt.Sprintf("%s/%s/%d@%s", issue.Repo.FullName(), path, issue.Index, setting.Domain)
}

func (issue *Issue) addLabel(e *xorm.Session, label *Label, doer *User) error {
return newIssueLabel(e, issue, label, doer)
}
Expand Down
17 changes: 16 additions & 1 deletion models/mail.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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()+">")
}

msg.SetHeader("In-Reply-To", "<"+issue.ReplyReference()+">")
msg.SetHeader("References", "<"+issue.ReplyReference()+">")

return msg
}

Expand Down