From 67ef0ea2b648fd72cc7f0e3ec50c5b2fa144b80c Mon Sep 17 00:00:00 2001 From: Aleksandr Nogikh Date: Fri, 10 Oct 2025 17:45:29 +0200 Subject: 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. --- pkg/email/lore/read.go | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'pkg/email/lore/read.go') 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 } -- cgit mrf-deployment