diff options
Diffstat (limited to 'worker/notmuch/worker.go')
-rw-r--r-- | worker/notmuch/worker.go | 49 |
1 files changed, 20 insertions, 29 deletions
diff --git a/worker/notmuch/worker.go b/worker/notmuch/worker.go index a36b44d4..2a11c1df 100644 --- a/worker/notmuch/worker.go +++ b/worker/notmuch/worker.go @@ -432,12 +432,30 @@ func (w *worker) handleFetchMessageHeaders( w.emitMessageInfoError(msg, uid, err) continue } - err = w.emitMessageInfo(m, msg) + info, err := m.MessageInfo() if err != nil { - w.w.Errorf("could not emit message info: %v", err) w.emitMessageInfoError(msg, uid, err) continue } + switch { + case len(w.headersExclude) > 0: + info.RFC822Headers = lib.LimitHeaders(info.RFC822Headers, w.headersExclude, true) + case len(w.headers) > 0: + info.RFC822Headers = lib.LimitHeaders(info.RFC822Headers, w.headers, false) + } + + switch msg { + case nil: + w.w.PostMessage(&types.MessageInfo{ + Info: info, + }, nil) + default: + w.w.PostMessage(&types.MessageInfo{ + Message: types.RespondTo(msg), + Info: info, + }, nil) + } + } w.done(msg) return nil @@ -679,33 +697,6 @@ func (w *worker) emitMessageInfoError(msg types.WorkerMessage, uid uint32, err e }, nil) } -func (w *worker) emitMessageInfo(m *Message, - parent types.WorkerMessage, -) error { - info, err := m.MessageInfo() - if err != nil { - return fmt.Errorf("could not get MessageInfo: %w", err) - } - switch { - case len(w.headersExclude) > 0: - info.RFC822Headers = lib.LimitHeaders(info.RFC822Headers, w.headersExclude, true) - case len(w.headers) > 0: - info.RFC822Headers = lib.LimitHeaders(info.RFC822Headers, w.headers, false) - } - switch parent { - case nil: - w.w.PostMessage(&types.MessageInfo{ - Info: info, - }, nil) - default: - w.w.PostMessage(&types.MessageInfo{ - Message: types.RespondTo(parent), - Info: info, - }, nil) - } - return nil -} - func (w *worker) emitLabelList() { tags := w.db.ListTags() w.w.PostMessage(&types.LabelList{Labels: tags}, nil) |