mirror of
https://github.com/mjl-/mox.git
synced 2025-07-12 17:04:39 +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:
@ -514,6 +514,31 @@ func (s *search) match0(sk searchKey) bool {
|
||||
case "MODSEQ":
|
||||
// ../rfc/7162:1045
|
||||
return s.m.ModSeq.Client() >= *sk.clientModseq
|
||||
case "SAVEDBEFORE", "SAVEDON", "SAVEDSINCE":
|
||||
// If we don't have a savedate for this message (for messages received before we
|
||||
// implemented this feature), we use the "internal date" (received timestamp) of
|
||||
// the message. ../rfc/8514:237
|
||||
rt := s.m.Received
|
||||
if s.m.SaveDate != nil {
|
||||
rt = *s.m.SaveDate
|
||||
}
|
||||
|
||||
skdt := sk.date.Format("2006-01-02")
|
||||
rdt := rt.Format("2006-01-02")
|
||||
switch sk.op {
|
||||
case "SAVEDBEFORE":
|
||||
return rdt < skdt
|
||||
case "SAVEDON":
|
||||
return rdt == skdt
|
||||
case "SAVEDSINCE":
|
||||
return rdt >= skdt
|
||||
}
|
||||
panic("missing case")
|
||||
case "SAVEDATESUPPORTED":
|
||||
// We return whether we have a savedate for this message. We support it on all
|
||||
// mailboxes, but we only have this metadata from the time we implemented this
|
||||
// feature.
|
||||
return s.m.SaveDate != nil
|
||||
}
|
||||
|
||||
if s.p == nil {
|
||||
|
Reference in New Issue
Block a user