diff options
| author | Aleksandr Nogikh <nogikh@google.com> | 2023-04-17 16:54:01 +0200 |
|---|---|---|
| committer | Aleksandr Nogikh <wp32pw@gmail.com> | 2023-04-18 15:45:30 +0200 |
| commit | d931e9f0c7a338e73ee7b5a36cf5b59b10802f09 (patch) | |
| tree | 259cec12fe1141fe22f45906f93a56756735e309 /pkg | |
| parent | 8e54598ac1d60e494d927f72c4d8b99cb71661e1 (diff) | |
pkg/email/lore: recognize more PATCH subjects
Diffstat (limited to 'pkg')
| -rw-r--r-- | pkg/email/lore/parse.go | 5 | ||||
| -rw-r--r-- | pkg/email/lore/parse_test.go | 12 |
2 files changed, 16 insertions, 1 deletions
diff --git a/pkg/email/lore/parse.go b/pkg/email/lore/parse.go index d9aedf98d..d0e4d4fe2 100644 --- a/pkg/email/lore/parse.go +++ b/pkg/email/lore/parse.go @@ -4,6 +4,7 @@ package lore import ( + "regexp" "sort" "strings" @@ -39,7 +40,7 @@ func DiscussionType(msg *email.Email) dashapi.DiscussionType { discType = dashapi.DiscussionReport } // This is very crude, but should work for now. - if strings.Contains(strings.ToLower(msg.Subject), "[patch") { + if patchSubjectRe.MatchString(strings.ToLower(msg.Subject)) { discType = dashapi.DiscussionPatch } else if strings.Contains(msg.Subject, "Monthly") { discType = dashapi.DiscussionReminder @@ -47,6 +48,8 @@ func DiscussionType(msg *email.Email) dashapi.DiscussionType { return discType } +var patchSubjectRe = regexp.MustCompile(`\[(?:(?:rfc|resend)\s+)*patch`) + type parseCtx struct { threads []*Thread messages map[string]*email.Email diff --git a/pkg/email/lore/parse_test.go b/pkg/email/lore/parse_test.go index a138139b5..84d3d0bdf 100644 --- a/pkg/email/lore/parse_test.go +++ b/pkg/email/lore/parse_test.go @@ -269,6 +269,18 @@ func TestDiscussionType(t *testing.T) { }, { msg: &email.Email{ + Subject: "[RFC PATCH] Bla-bla", + }, + ret: dashapi.DiscussionPatch, + }, + { + msg: &email.Email{ + Subject: "[RESEND PATCH] Bla-bla", + }, + ret: dashapi.DiscussionPatch, + }, + { + msg: &email.Email{ Subject: "[syzbot] Monthly ext4 report", OwnEmail: true, }, |
