From 4fbf89114af1e1cc49ed525f0b28c49411115631 Mon Sep 17 00:00:00 2001 From: Aleksandr Nogikh Date: Wed, 12 Apr 2023 11:49:19 +0200 Subject: dashboard: separate DiscussionReport and DiscussionMention DiscussionReport are the discussions started by syzbot. All other discussions that Cc syzbot or mention its bugs are DiscussionMention. --- pkg/email/lore/parse.go | 5 ++++- pkg/email/lore/parse_test.go | 22 +++++++++++++++------- 2 files changed, 19 insertions(+), 8 deletions(-) (limited to 'pkg/email') diff --git a/pkg/email/lore/parse.go b/pkg/email/lore/parse.go index d2dc9c04b..42a0d9007 100644 --- a/pkg/email/lore/parse.go +++ b/pkg/email/lore/parse.go @@ -34,7 +34,10 @@ func Threads(emails []*email.Email) []*Thread { // DiscussionType extracts the specific discussion type from an email. func DiscussionType(msg *email.Email) dashapi.DiscussionType { - discType := dashapi.DiscussionReport + discType := dashapi.DiscussionMention + if msg.OwnEmail { + discType = dashapi.DiscussionReport + } // This is very crude, but should work for now. if strings.Contains(msg.Subject, "PATCH") { discType = dashapi.DiscussionPatch diff --git a/pkg/email/lore/parse_test.go b/pkg/email/lore/parse_test.go index 2343a7c26..b521d694f 100644 --- a/pkg/email/lore/parse_test.go +++ b/pkg/email/lore/parse_test.go @@ -86,7 +86,7 @@ Content-Type: text/plain Patch`, // An orphaned reply from a human. `Date: Sun, 7 May 2017 19:57:00 -0700 -Subject: [syzbot] Some bug 2 +Subject: Another bug discussion In-Reply-To: Message-ID: From: person@email.com @@ -113,7 +113,7 @@ Bug report`, "": { Subject: "Thread A", MessageID: "", - Type: dashapi.DiscussionReport, + Type: dashapi.DiscussionMention, Messages: []*email.Email{ { MessageID: "", @@ -198,9 +198,9 @@ Bug report`, }, }, "": { - Subject: "[syzbot] Some bug 2", + Subject: "Another bug discussion", MessageID: "", - Type: dashapi.DiscussionReport, + Type: dashapi.DiscussionMention, BugIDs: []string{"4564456"}, Messages: []*email.Email{ { @@ -209,7 +209,7 @@ Bug report`, Date: time.Date(2017, time.May, 7, 19, 57, 0, 0, zone), BugIDs: []string{"4564456"}, Cc: []string{"person@email.com"}, - Subject: "[syzbot] Some bug 2", + Subject: "Another bug discussion", Author: "person@email.com", Command: email.CmdNone, }, @@ -263,16 +263,24 @@ func TestDiscussionType(t *testing.T) { }, { msg: &email.Email{ - Subject: "[syzbot] Monthly ext4 report", + Subject: "[syzbot] Monthly ext4 report", + OwnEmail: true, }, ret: dashapi.DiscussionReminder, }, { msg: &email.Email{ - Subject: "[syzbot] WARNING in abcd", + Subject: "[syzbot] WARNING in abcd", + OwnEmail: true, }, ret: dashapi.DiscussionReport, }, + { + msg: &email.Email{ + Subject: "Some human-reported bug", + }, + ret: dashapi.DiscussionMention, + }, } for _, test := range tests { got := DiscussionType(test.msg) -- cgit mrf-deployment