From ed0c5205629488503bdf61058c784db96dd9d8bc Mon Sep 17 00:00:00 2001 From: Mechiel Lukkien Date: Sun, 21 Apr 2024 20:45:06 +0200 Subject: [PATCH] webmail: single db transaction while fetching parsed message --- webmail/api.go | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/webmail/api.go b/webmail/api.go index 2715c4b..6c79770 100644 --- a/webmail/api.go +++ b/webmail/api.go @@ -169,23 +169,19 @@ func (Webmail) ParsedMessage(ctx context.Context, msgID int64) (pm ParsedMessage log.Check(err, "closing account") }() - var m store.Message xdbread(ctx, acc, func(tx *bstore.Tx) { - m = xmessageID(ctx, tx, msgID) - }) + m := xmessageID(ctx, tx, msgID) - state := msgState{acc: acc} - defer state.clear() - pm, err = parsedMessage(log, m, &state, true, false) - xcheckf(ctx, err, "parsing message") + state := msgState{acc: acc} + defer state.clear() + pm, err = parsedMessage(log, m, &state, true, false) + xcheckf(ctx, err, "parsing message") - if len(pm.envelope.From) == 1 { - xdbread(ctx, acc, func(tx *bstore.Tx) { + if len(pm.envelope.From) == 1 { pm.ViewMode, err = fromAddrViewMode(tx, pm.envelope.From[0]) xcheckf(ctx, err, "looking up view mode for from address") - }) - } - + } + }) return }