diff options
| author | Aleksandr Nogikh <nogikh@google.com> | 2023-04-12 14:11:05 +0200 |
|---|---|---|
| committer | Aleksandr Nogikh <wp32pw@gmail.com> | 2023-04-12 20:13:51 +0200 |
| commit | 6ecb91f6d1adf05bca5bf9c6acfbcc652642609f (patch) | |
| tree | 90b29cb3fce1036c1f9181028404b96b2191c4d6 /pkg | |
| parent | a21588f3fe5342d5f0d565c589da83a53a0bd095 (diff) | |
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.
Diffstat (limited to 'pkg')
| -rw-r--r-- | pkg/email/lore/parse.go | 2 | ||||
| -rw-r--r-- | pkg/email/lore/parse_test.go | 6 |
2 files changed, 7 insertions, 1 deletions
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 @@ -263,6 +263,12 @@ func TestDiscussionType(t *testing.T) { }, { msg: &email.Email{ + Subject: "[patch v3] Bla-bla", + }, + ret: dashapi.DiscussionPatch, + }, + { + msg: &email.Email{ Subject: "[syzbot] Monthly ext4 report", OwnEmail: true, }, |
