implement imap savedate extension, rfc 8514

it makes a new field available on stored messages. not when they they were
received (over smtp) or appended to the mailbox (over imap), but when they were
last "saved" in the mailbox. copy/move of a message (eg to the trash) resets
the "savedate" value. this helps implement "remove messages from trash after X
days".
This commit is contained in:
Mechiel Lukkien
2025-02-19 17:11:20 +01:00
parent cbe5bb235c
commit 7288e038e6
16 changed files with 136 additions and 10 deletions

View File

@ -8,6 +8,7 @@ import (
"io"
"os"
"sort"
"time"
"golang.org/x/exp/maps"
@ -381,6 +382,7 @@ func (x XOps) MessageMoveTx(ctx context.Context, log mlog.Log, acc *store.Accoun
var mbSrc store.Mailbox
keywords := map[string]struct{}{}
now := time.Now()
for _, mid := range messageIDs {
m := x.messageID(ctx, tx, mid)
@ -436,6 +438,7 @@ func (x XOps) MessageMoveTx(ctx context.Context, log mlog.Log, acc *store.Accoun
m.ModSeq = modseq
mbDst.UIDNext++
m.JunkFlagsForMailbox(mbDst, conf)
m.SaveDate = &now
err = tx.Update(&m)
x.Checkf(ctx, err, "updating moved message in database")