aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/email/lore/read.go
diff options
context:
space:
mode:
authorAleksandr Nogikh <nogikh@google.com>2025-10-10 17:45:29 +0200
committerAleksandr Nogikh <nogikh@google.com>2025-10-21 16:05:49 +0000
commit67ef0ea2b648fd72cc7f0e3ec50c5b2fa144b80c (patch)
tree998f1ff64ab65b94118ccd229c0d725e7b6d97e7 /pkg/email/lore/read.go
parent9832ed61ae41048a549b0194edc9dcade0851e76 (diff)
pkg/email/lore: wrap the Email object
Wrapping the email.Email object will let us add lore-specific fields to it at a later point.
Diffstat (limited to 'pkg/email/lore/read.go')
-rw-r--r--pkg/email/lore/read.go19
1 files changed, 14 insertions, 5 deletions
diff --git a/pkg/email/lore/read.go b/pkg/email/lore/read.go
index d4e68cf33..90a462d9a 100644
--- a/pkg/email/lore/read.go
+++ b/pkg/email/lore/read.go
@@ -36,19 +36,28 @@ func ReadArchive(repo vcs.Repo, afterCommit string, afterTime time.Time) ([]Emai
return ret, nil
}
-func (er *EmailReader) Parse(emails, domains []string) (*email.Email, error) {
+type Email struct {
+ *email.Email
+ HasPatch bool
+}
+
+func (er *EmailReader) Parse(emails, domains []string) (*Email, error) {
body, err := er.Read()
if err != nil {
return nil, err
}
+ return emailFromRaw(body, emails, domains)
+}
+
+func emailFromRaw(body []byte, emails, domains []string) (*Email, error) {
msg, err := email.Parse(bytes.NewReader(body), emails, nil, domains)
if err != nil {
return nil, err
}
+ ret := &Email{Email: msg}
// Keep memory consumption low.
- msg.Body = ""
- msg.Patch = ""
- // TODO: We definitely don't care about the patch here. Add an option to avoid extracting it?
+ ret.Body = ""
+ ret.Patch = ""
// TODO: If emails/domains are nil, we also don't need to parse the body at all.
- return msg, nil
+ return ret, nil
}