imapserver: implement rfc 9590, returning metadata in the extended list command

only with "return" including "metadata". so clients can quickly get certain
metadata (eg for display, such as a color) for mailboxes.

this also adds a protocol token type "mailboxt" that properly encodes to utf7
if required.
This commit is contained in:
Mechiel Lukkien
2025-02-23 22:12:18 +01:00
parent 2809136451
commit 0ed820e3b0
8 changed files with 120 additions and 24 deletions

View File

@ -460,11 +460,14 @@ func (c *Conn) xuntagged() Untagged {
var isString bool
if c.take('~') {
value = c.xliteral()
} else {
} else if c.peek('"') {
value = []byte(c.xstring())
isString = true
// note: the abnf also allows nstring, but that only makes sense when the
// production rule is used in the setmetadata command. ../rfc/5464:831
} else {
// For response to extended list.
c.xtake("nil")
}
r.Annotations = append(r.Annotations, Annotation{key, isString, value})

View File

@ -37,6 +37,7 @@ const (
CapSaveDate Capability = "SAVEDATE" // ../rfc/8514
CapCreateSpecialUse Capability = "CREATE-SPECIAL-USE" // ../rfc/6154:296
CapCompressDeflate Capability = "COMPRESS=DEFLATE" // ../rfc/4978:65
CapListMetadata Capability = "LIST-METADTA" // ../rfc/9590:73
)
// Status is the tagged final result of a command.
@ -242,8 +243,10 @@ type UntaggedMetadataKeys struct {
Keys []string
}
// Annotation is a metadata server of mailbox annotation.
type Annotation struct {
Key string
// Nil is represented by IsString false and a nil Value.
IsString bool
Value []byte
}