aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/email/parser.go
diff options
context:
space:
mode:
authorAleksandr Nogikh <nogikh@google.com>2025-07-10 10:37:19 +0200
committerAleksandr Nogikh <nogikh@google.com>2025-07-10 08:52:48 +0000
commite2c7870cb29ae33156ef5f5e058d350e0d485f04 (patch)
tree703179ce919cc4f3ea32ff71936d045f8114be39 /pkg/email/parser.go
parent2a9a3ab9ac5c9f66069e751a394482a38b36e29f (diff)
pkg/email: share raw email addresses
These will be necessary to properly route emails in dashboard.
Diffstat (limited to 'pkg/email/parser.go')
-rw-r--r--pkg/email/parser.go24
1 files changed, 19 insertions, 5 deletions
diff --git a/pkg/email/parser.go b/pkg/email/parser.go
index 63f758bd2..3ebd7ac08 100644
--- a/pkg/email/parser.go
+++ b/pkg/email/parser.go
@@ -30,8 +30,9 @@ type Email struct {
Author string
OwnEmail bool
Cc []string
- Body string // text/plain part
- Patch string // attached patch, if any
+ RawCc []string // unstripped emails
+ Body string // text/plain part
+ Patch string // attached patch, if any
Commands []*SingleCommand
}
@@ -178,7 +179,7 @@ func Parse(r io.Reader, ownEmails, goodLists, domains []string) (*Email, error)
}
date, _ := mail.ParseDate(msg.Header.Get("Date"))
email := &Email{
- BugIDs: dedupBugIDs(bugIDs),
+ BugIDs: unique(bugIDs),
MessageID: msg.Header.Get("Message-ID"),
InReplyTo: extractInReplyTo(msg.Header),
Date: date,
@@ -188,6 +189,7 @@ func Parse(r io.Reader, ownEmails, goodLists, domains []string) (*Email, error)
MailingList: mailingList,
Subject: subject,
Cc: ccList,
+ RawCc: mergeRawAddresses(from, originalFroms, to, cc),
Body: bodyStr,
Patch: patch,
Commands: cmds,
@@ -500,8 +502,8 @@ func extractBodyBugIDs(body string, ownEmailMap map[string]bool, domains []strin
return ids
}
-func dedupBugIDs(list []string) []string {
- // We should preserve the original order of IDs.
+func unique(list []string) []string {
+ // We preserve the original order since it's necessary for bug IDs.
var ret []string
dup := map[string]struct{}{}
for _, v := range list {
@@ -541,6 +543,18 @@ func MergeEmailLists(lists ...[]string) []string {
return result
}
+func mergeRawAddresses(lists ...[]*mail.Address) []string {
+ var emails []string
+ for _, list := range lists {
+ for _, item := range list {
+ emails = append(emails, item.Address)
+ }
+ }
+ emails = unique(emails)
+ sort.Strings(emails)
+ return emails
+}
+
func RemoveFromEmailList(list []string, toRemove string) []string {
var result []string
toRemove = CanonicalEmail(toRemove)