From 334641584880cd238fc32dc6f436e7e10efdf3de Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Fri, 23 Feb 2018 11:24:43 +0100 Subject: dashboard/app: prefix email replies with Re: This plays an important role at least for job replies. If we CC a kernel mailing list and it uses Patchwork, then any emails with a patch attached create a new patch entry pending for review. The prefix makes Patchwork treat it as a comment for a previous patch. --- dashboard/app/email_test.go | 6 +++--- dashboard/app/jobs_test.go | 2 +- dashboard/app/reporting_email.go | 13 +++++++++++-- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/dashboard/app/email_test.go b/dashboard/app/email_test.go index 1afac448e..56d263c63 100644 --- a/dashboard/app/email_test.go +++ b/dashboard/app/email_test.go @@ -146,7 +146,7 @@ For more options, visit https://groups.google.com/d/optout. config.Namespaces["test2"].Reporting[0].Config.(*EmailConfig).Email, } c.expectEQ(msg.To, to) - c.expectEQ(msg.Subject, crash.Title) + c.expectEQ(msg.Subject, "Re: "+crash.Title) c.expectEQ(len(msg.Attachments), 3) c.expectEQ(msg.Attachments[0].Name, "raw.log.txt") c.expectEQ(msg.Attachments[0].Data, crash.Log) @@ -283,7 +283,7 @@ Content-Type: text/plain c.expectEQ(sender, fromAddr(c.ctx)) c.expectEQ(msg.To, []string{"another@another.com", "bar@foo.com", "bugs@syzkaller.com", "default@maintainers.com", "foo@bar.com", "new@new.com", "qux@qux.com"}) - c.expectEQ(msg.Subject, crash.Title) + c.expectEQ(msg.Subject, "Re: "+crash.Title) c.expectEQ(len(msg.Attachments), 4) c.expectEQ(msg.Attachments[0].Name, "raw.log.txt") c.expectEQ(msg.Attachments[0].Data, crash.Log) @@ -334,7 +334,7 @@ Content-Type: text/plain c.expectEQ(len(c.emailSink), 1) msg := <-c.emailSink c.expectEQ(msg.To, []string{""}) - c.expectEQ(msg.Subject, crash.Title) + c.expectEQ(msg.Subject, "Re: title1") c.expectEQ(msg.Headers["In-Reply-To"], []string{""}) if !strings.Contains(msg.Body, `> #syz bad-command diff --git a/dashboard/app/jobs_test.go b/dashboard/app/jobs_test.go index f5124a382..40de2ce9b 100644 --- a/dashboard/app/jobs_test.go +++ b/dashboard/app/jobs_test.go @@ -136,7 +136,7 @@ func TestJob(t *testing.T) { msg := <-c.emailSink to := email.MergeEmailLists([]string{"test@requester.com", "somebody@else.com", mailingList}) c.expectEQ(msg.To, to) - c.expectEQ(msg.Subject, crash.Title) + c.expectEQ(msg.Subject, "Re: "+crash.Title) c.expectEQ(len(msg.Attachments), 3) c.expectEQ(msg.Attachments[0].Name, "patch.diff") c.expectEQ(msg.Attachments[0].Data, []byte(patch)) diff --git a/dashboard/app/reporting_email.go b/dashboard/app/reporting_email.go index d41a503b8..bb2931325 100644 --- a/dashboard/app/reporting_email.go +++ b/dashboard/app/reporting_email.go @@ -39,7 +39,15 @@ func init() { } } -const emailType = "email" +const ( + emailType = "email" + // This plays an important role at least for job replies. + // If we CC a kernel mailing list and it uses Patchwork, + // then any emails with a patch attached create a new patch + // entry pending for review. The prefix makes Patchwork + // treat it as a comment for a previous patch. + replySubjectPrefix = "Re: " +) var mailingLists map[string]bool @@ -429,6 +437,7 @@ func sendMailTemplate(c context.Context, subject, from string, to []string, repl } if replyTo != "" { msg.Headers = mail.Header{"In-Reply-To": []string{replyTo}} + msg.Subject = replySubjectPrefix + msg.Subject } return sendEmail(c, msg) } @@ -448,7 +457,7 @@ func replyTo(c context.Context, msg *email.Email, reply string, attachment *aema Sender: from, To: []string{msg.From}, Cc: msg.Cc, - Subject: msg.Subject, + Subject: replySubjectPrefix + msg.Subject, Body: email.FormReply(msg.Body, reply), Attachments: attachments, Headers: mail.Header{"In-Reply-To": []string{msg.MessageID}}, -- cgit mrf-deployment