From 6ecb91f6d1adf05bca5bf9c6acfbcc652642609f Mon Sep 17 00:00:00 2001 From: Aleksandr Nogikh Date: Wed, 12 Apr 2023 14:11:05 +0200 Subject: pkg/email/lore: better classify emails Patches are not always spelled upper case. Also, looking for just PATCH may lead to false positives, so first put the subject to lower case and then look for the "[patch" substring. --- pkg/email/lore/parse.go | 2 +- pkg/email/lore/parse_test.go | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'pkg') diff --git a/pkg/email/lore/parse.go b/pkg/email/lore/parse.go index 42a0d9007..d9aedf98d 100644 --- a/pkg/email/lore/parse.go +++ b/pkg/email/lore/parse.go @@ -39,7 +39,7 @@ func DiscussionType(msg *email.Email) dashapi.DiscussionType { discType = dashapi.DiscussionReport } // This is very crude, but should work for now. - if strings.Contains(msg.Subject, "PATCH") { + if strings.Contains(strings.ToLower(msg.Subject), "[patch") { discType = dashapi.DiscussionPatch } else if strings.Contains(msg.Subject, "Monthly") { discType = dashapi.DiscussionReminder diff --git a/pkg/email/lore/parse_test.go b/pkg/email/lore/parse_test.go index b521d694f..a138139b5 100644 --- a/pkg/email/lore/parse_test.go +++ b/pkg/email/lore/parse_test.go @@ -261,6 +261,12 @@ func TestDiscussionType(t *testing.T) { }, ret: dashapi.DiscussionPatch, }, + { + msg: &email.Email{ + Subject: "[patch v3] Bla-bla", + }, + ret: dashapi.DiscussionPatch, + }, { msg: &email.Email{ Subject: "[syzbot] Monthly ext4 report", -- cgit mrf-deployment