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

@ -5,6 +5,7 @@ import (
"io"
"strconv"
"strings"
"time"
)
func (c *Conn) recorded() string {
@ -686,6 +687,19 @@ func (c *Conn) xmsgatt1() FetchAttr {
c.xspace()
return FetchInternalDate(c.xquoted()) // todo: parsed time
case "SAVEDATE":
c.xspace()
var t *time.Time
if c.peek('"') {
s := c.xquoted()
v, err := time.Parse("_2-Jan-2006 15:04:05 -0700", s)
c.xcheckf(err, "parsing savedate")
t = &v
} else {
c.xtake("nil")
}
return FetchSaveDate{t}
case "RFC822.SIZE":
c.xspace()
return FetchRFC822Size(c.xint64())