From 834650a0c890ce23f24e3ef5739aae79dcd054c1 Mon Sep 17 00:00:00 2001 From: Aleksandr Nogikh Date: Wed, 14 Dec 2022 20:56:09 +0100 Subject: dashboard: mention subsystems in the email Subject --- dashboard/app/email_test.go | 6 ++++++ dashboard/app/reporting_email.go | 15 ++++++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/dashboard/app/email_test.go b/dashboard/app/email_test.go index 05f312c6c..29c76da9f 100644 --- a/dashboard/app/email_test.go +++ b/dashboard/app/email_test.go @@ -859,6 +859,12 @@ func TestSubjectTitleParser(t *testing.T) { outTitle: "", outSeq: 0, }, + { + // Make sure we delete filesystem tags. + inSubject: "Re: [syzbot] [ntfs3?] [ext4?] kernel BUG in blk_mq_dispatch_rq_list (4)", + outTitle: "kernel BUG in blk_mq_dispatch_rq_list", + outSeq: 3, + }, } p := subjectTitleParser{} diff --git a/dashboard/app/reporting_email.go b/dashboard/app/reporting_email.go index cb09c80e9..4ad745ca6 100644 --- a/dashboard/app/reporting_email.go +++ b/dashboard/app/reporting_email.go @@ -271,8 +271,17 @@ func emailReport(c context.Context, rep *dashapi.BugReport) error { if err := mailTemplates.ExecuteTemplate(body, templ, rep); err != nil { return fmt.Errorf("failed to execute %v template: %v", templ, err) } - log.Infof(c, "sending email %q to %q", rep.Title, to) - return sendMailText(c, cfg, rep.Title, from, to, rep.ExtID, body.String()) + title := generateEmailBugTitle(rep, cfg) + log.Infof(c, "sending email %q to %q", title, to) + return sendMailText(c, cfg, title, from, to, rep.ExtID, body.String()) +} + +func generateEmailBugTitle(rep *dashapi.BugReport, emailConfig *EmailConfig) string { + title := "" + for i := len(rep.Subsystems) - 1; i >= 0; i-- { + title = fmt.Sprintf("[%s?] %s", rep.Subsystems[i].Name, title) + } + return title + rep.Title } // handleIncomingMail is the entry point for incoming emails. @@ -626,7 +635,7 @@ func (p *subjectTitleParser) prepareRegexps() { } } rePrefixes := `^(?:(?:` + strings.Join(stripPrefixes, "|") + `)\s*)*` - p.pattern = regexp.MustCompile(rePrefixes + `(.*?)(?:\s\((\d+)\))?$`) + p.pattern = regexp.MustCompile(rePrefixes + `(?:\[[^\]]+\]\s*)*(.*?)(?:\s\((\d+)\))?$`) }) } -- cgit mrf-deployment