From 31d2f5be3cec88d82924816c3482253557999e63 Mon Sep 17 00:00:00 2001 From: Tim Culverhouse Date: Mon, 7 Nov 2022 10:15:49 -0600 Subject: message-info: add explicit References field Add an explicit References field to message info. This is useful for storing information needed for threading without storing all of the header values, keeping system RAM usage lower. Signed-off-by: Tim Culverhouse Tested-by: Inwit Acked-by: Robin Jarry --- worker/imap/cache.go | 4 ++++ worker/imap/fetch.go | 4 ++++ worker/lib/parse.go | 5 +++++ 3 files changed, 13 insertions(+) (limited to 'worker') diff --git a/worker/imap/cache.go b/worker/imap/cache.go index 17a622d6..c32131d3 100644 --- a/worker/imap/cache.go +++ b/worker/imap/cache.go @@ -118,6 +118,10 @@ func (w *IMAPWorker) getCachedHeaders(msg *types.FetchMessageHeaders) []uint32 { Uid: ch.Uid, RFC822Headers: hdr, } + refs, err := hdr.MsgIDList("references") + if err != nil { + mi.Refs = refs + } logging.Debugf("located cached header %s.%s", uv, u) w.worker.PostMessage(&types.MessageInfo{ Message: types.RespondTo(msg), diff --git a/worker/imap/fetch.go b/worker/imap/fetch.go index 3b9c7862..f3aad36e 100644 --- a/worker/imap/fetch.go +++ b/worker/imap/fetch.go @@ -62,6 +62,10 @@ func (imapw *IMAPWorker) handleFetchMessageHeaders( RFC822Headers: header, Uid: _msg.Uid, } + refs, err := header.MsgIDList("references") + if err != nil { + info.Refs = refs + } imapw.worker.PostMessage(&types.MessageInfo{ Message: types.RespondTo(msg), Info: info, diff --git a/worker/lib/parse.go b/worker/lib/parse.go index 6b33d246..7e1f36f2 100644 --- a/worker/lib/parse.go +++ b/worker/lib/parse.go @@ -348,11 +348,16 @@ func MessageHeaders(raw RawMessage) (*models.MessageInfo, error) { if err != nil { return nil, err } + refs, err := h.MsgIDList("references") + if err != nil { + return nil, err + } return &models.MessageInfo{ Envelope: env, Flags: flags, Labels: labels, InternalDate: recDate, + Refs: refs, Size: 0, Uid: raw.UID(), Error: parseErr, -- cgit