After queueing a message in the web api's, prevent context cancelation from completing message changes

Adding to the queue is done in a transaction, the queue db file is mox-global.
Appending the message to the Sent folder, removing it from Drafts, marking the
original message as answered/forwarded, is done in a separate database
transaction that gets the ctx passed in. If the ctx was canceled in between,
the queueing was finished, but the rest wasn't completed.

Reported by mteege, thanks!
This commit is contained in:
Mechiel Lukkien
2025-03-23 11:07:39 +01:00
parent b0e4dcdb61
commit b37faa06bd
2 changed files with 7 additions and 0 deletions

View File

@ -1048,6 +1048,9 @@ func (s server) Send(ctx context.Context, req webapi.SendRequest) (resp webapi.S
xcheckf(err, "adding messages to the delivery queue")
metricSubmission.WithLabelValues("ok").Inc()
// Message has been added to the queue. Ensure we finish the work.
ctx = context.WithoutCancel(ctx)
if req.SaveSent {
// Append message to Sent mailbox and mark original messages as answered/forwarded.
acc.WithRLock(func() {