mirror of
https://github.com/mjl-/mox.git
synced 2025-07-12 17:44:35 +03:00
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:
@ -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())
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
// Capability is a known string for with the ENABLED and CAPABILITY command.
|
||||
@ -455,6 +456,13 @@ type Address struct {
|
||||
type FetchInternalDate string // todo: parsed time
|
||||
func (f FetchInternalDate) Attr() string { return "INTERNALDATE" }
|
||||
|
||||
// "SAVEDATE" fetch response. ../rfc/8514:265
|
||||
type FetchSaveDate struct {
|
||||
SaveDate *time.Time // nil means absent for message.
|
||||
}
|
||||
|
||||
func (f FetchSaveDate) Attr() string { return "SAVEDATE" }
|
||||
|
||||
// "RFC822.SIZE" fetch response.
|
||||
type FetchRFC822Size int64
|
||||
|
||||
|
Reference in New Issue
Block a user