mirror of
https://github.com/mjl-/mox.git
synced 2025-07-13 13:34:37 +03:00
Improve expunged message/UID tracking in IMAP sessions, track synchronization history for mailboxes/annotations.
Keeping the message files around, and the message details in the database, is useful for IMAP sessions that haven't seen/processed the removal of a message yet and try to fetch it. Before, we would return errors. Similarly, a session that has a mailbox selected that is removed can (at least in theory) still read messages. The mechanics to do this need keeping removed mailboxes around too. JMAP needs that anyway, so we now keep modseq/createseq/expunged history for mailboxes too. And while we're at it, for annotations as well. For future JMAP support, we now also keep the mailbox parent id around for a mailbox, with an upgrade step to set the field for existing mailboxes and fixing up potential missing parents (which could possibly have happened in an obscure corner case that I doubt anyone ran into).
This commit is contained in:
@ -933,6 +933,10 @@ func PrepareStaticConfig(ctx context.Context, log mlog.Log, configFile string, c
|
||||
// DefaultMailboxes is deprecated.
|
||||
for _, mb := range c.DefaultMailboxes {
|
||||
checkMailboxNormf(mb, "default mailbox")
|
||||
// We don't create parent mailboxes for default mailboxes.
|
||||
if ParentMailboxName(mb) != "" {
|
||||
addErrorf("default mailbox cannot be a child mailbox")
|
||||
}
|
||||
}
|
||||
checkSpecialUseMailbox := func(nameOpt string) {
|
||||
if nameOpt != "" {
|
||||
@ -940,6 +944,10 @@ func PrepareStaticConfig(ctx context.Context, log mlog.Log, configFile string, c
|
||||
if strings.EqualFold(nameOpt, "inbox") {
|
||||
addErrorf("initial mailbox cannot be set to Inbox (Inbox is always created)")
|
||||
}
|
||||
// We don't currently create parent mailboxes for initial mailboxes.
|
||||
if ParentMailboxName(nameOpt) != "" {
|
||||
addErrorf("initial mailboxes cannot be child mailboxes")
|
||||
}
|
||||
}
|
||||
}
|
||||
checkSpecialUseMailbox(c.InitialMailboxes.SpecialUse.Archive)
|
||||
@ -952,6 +960,9 @@ func PrepareStaticConfig(ctx context.Context, log mlog.Log, configFile string, c
|
||||
if strings.EqualFold(name, "inbox") {
|
||||
addErrorf("initial regular mailbox cannot be set to Inbox (Inbox is always created)")
|
||||
}
|
||||
if ParentMailboxName(name) != "" {
|
||||
addErrorf("initial mailboxes cannot be child mailboxes")
|
||||
}
|
||||
}
|
||||
|
||||
checkTransportSMTP := func(name string, isTLS bool, t *config.TransportSMTP) {
|
||||
|
15
mox-/parentname.go
Normal file
15
mox-/parentname.go
Normal file
@ -0,0 +1,15 @@
|
||||
package mox
|
||||
|
||||
import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
// ParentMailboxName returns the name of the parent mailbox, returning empty if
|
||||
// there is no parent.
|
||||
func ParentMailboxName(name string) string {
|
||||
i := strings.LastIndex(name, "/")
|
||||
if i < 0 {
|
||||
return ""
|
||||
}
|
||||
return name[:i]
|
||||
}
|
Reference in New Issue
Block a user