From ec77d7cc1b8bc1c3058c2bfdcfcccb781f338f20 Mon Sep 17 00:00:00 2001 From: Aleksandr Nogikh Date: Tue, 11 Apr 2023 16:29:17 +0200 Subject: pkg/email: expose OwnEmail flag We anyway already extract this information, there's no sense in extracting it again in other places. --- dashboard/app/reporting_email.go | 2 +- pkg/email/parser.go | 2 ++ pkg/email/parser_test.go | 1 + tools/syz-lore/query_lkml.go | 11 +---------- 4 files changed, 5 insertions(+), 11 deletions(-) diff --git a/dashboard/app/reporting_email.go b/dashboard/app/reporting_email.go index 8b260a3d3..67c8258e8 100644 --- a/dashboard/app/reporting_email.go +++ b/dashboard/app/reporting_email.go @@ -577,7 +577,7 @@ func processDiscussionEmail(c context.Context, msg *email.Email, source dashapi. msgType: dType, bugIDs: extIDs, inReplyTo: msg.InReplyTo, - external: ownEmail(c) != msg.Author, + external: !msg.OwnEmail, time: msg.Date, }) if err != nil { diff --git a/pkg/email/parser.go b/pkg/email/parser.go index 77b063055..5b472a57e 100644 --- a/pkg/email/parser.go +++ b/pkg/email/parser.go @@ -27,6 +27,7 @@ type Email struct { Subject string MailingList string Author string + OwnEmail bool Cc []string Body string // text/plain part Patch string // attached patch, if any @@ -173,6 +174,7 @@ func Parse(r io.Reader, ownEmails, goodLists, domains []string) (*Email, error) Date: date, Link: link, Author: author, + OwnEmail: fromMe, MailingList: mailingList, Subject: subject, Cc: ccList, diff --git a/pkg/email/parser_test.go b/pkg/email/parser_test.go index 81a532648..33b2413ce 100644 --- a/pkg/email/parser_test.go +++ b/pkg/email/parser_test.go @@ -406,6 +406,7 @@ last line`, Date: time.Date(2017, time.May, 7, 19, 54, 0, 0, parseTestZone), Subject: "test subject", Author: "foo@bar.com", + OwnEmail: true, Cc: []string{"bob@example.com"}, Body: `text body last line`, diff --git a/tools/syz-lore/query_lkml.go b/tools/syz-lore/query_lkml.go index 61cb848f5..4b59b6393 100644 --- a/tools/syz-lore/query_lkml.go +++ b/tools/syz-lore/query_lkml.go @@ -52,7 +52,7 @@ func main() { for _, m := range thread.Messages { messages = append(messages, dashapi.DiscussionMessage{ ID: m.MessageID, - External: !emailInList(emails, m.Author), + External: !m.OwnEmail, Time: m.Date, }) } @@ -151,12 +151,3 @@ func processArchives(dir string, emails, domains []string) []*lore.Thread { log.Printf("%d threads are related to syzbot", len(ret)) return ret } - -func emailInList(list []string, email string) bool { - for _, str := range list { - if str == email { - return true - } - } - return false -} -- cgit mrf-deployment