implement storing non-system/well-known flags (keywords) for messages and mailboxes, with imap

the mailbox select/examine responses now return all flags used in a mailbox in
the FLAGS response. and indicate in the PERMANENTFLAGS response that clients
can set new keywords. we store these values on the new Message.Keywords field.
system/well-known flags are still in Message.Flags, so we're recognizing those
and handling them separately.

the imap store command handles the new flags. as does the append command, and
the search command.

we store keywords in a mailbox when a message in that mailbox gets the keyword.
we don't automatically remove the keywords from a mailbox. there is currently
no way at all to remove a keyword from a mailbox.

the import commands now handle non-system/well-known keywords too, when
importing from mbox/maildir.

jmap requires keyword support, so best to get it out of the way now.
This commit is contained in:
Mechiel Lukkien
2023-06-24 00:24:43 +02:00
parent afefadf2c0
commit 40163bd145
30 changed files with 1927 additions and 145 deletions

View File

@ -178,9 +178,9 @@ func (c *Conn) xrespCode() (string, CodeArg) {
l := []string{} // Must be non-nil.
if c.take(' ') {
c.xtake("(")
l = []string{c.xflag()}
l = []string{c.xflagPerm()}
for c.take(' ') {
l = append(l, c.xflag())
l = append(l, c.xflagPerm())
}
c.xtake(")")
}
@ -694,10 +694,13 @@ func (c *Conn) xliteral() []byte {
// ../rfc/9051:6565
// todo: stricter
func (c *Conn) xflag() string {
func (c *Conn) xflag0(allowPerm bool) string {
s := ""
if c.take('\\') {
s = "\\"
s = `\`
if allowPerm && c.take('*') {
return `\*`
}
} else if c.take('$') {
s = "$"
}
@ -705,6 +708,14 @@ func (c *Conn) xflag() string {
return s
}
func (c *Conn) xflag() string {
return c.xflag0(false)
}
func (c *Conn) xflagPerm() string {
return c.xflag0(true)
}
func (c *Conn) xsection() string {
c.xtake("[")
s := c.xtakeuntil(']')