Skip to content

Commit

Permalink
imapserver: always send special-use attributes for mailboxes
Browse files Browse the repository at this point in the history
even if not asked for with the "return (special-use)" extended list parameter.
macos x mail does not request the special-use flags, but will use them when present.

for issue #66, thanks x8x for providing the imap protocol transcript that
showed how it is done!
  • Loading branch information
mjl- committed Sep 23, 2023
1 parent f19f16b commit 55febe3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
7 changes: 4 additions & 3 deletions imapserver/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func (c *conn) cmdList(tag, cmd string, p *parser) {
p.xspace()
patterns, isList := p.xmboxOrPat()
isExtended = isExtended || isList
var retSubscribed, retChildren, retSpecialUse bool
var retSubscribed, retChildren bool
var retStatusAttrs []string
if p.take(" RETURN (") {
isExtended = true
Expand All @@ -79,7 +79,8 @@ func (c *conn) cmdList(tag, cmd string, p *parser) {
retChildren = true
case "SPECIAL-USE":
// ../rfc/6154:478
retSpecialUse = true
// We always include special-use mailbox flags. Mac OS X Mail 16.0 (sept 2023) does
// not ask for the flags, but does use them when given. ../rfc/6154:146
case "STATUS":
// ../rfc/9051:7072 ../rfc/5819:181
p.xspace()
Expand Down Expand Up @@ -189,7 +190,7 @@ func (c *conn) cmdList(tag, cmd string, p *parser) {
if !listSubscribed && retSubscribed && info.subscribed {
flags = append(flags, bare(`\Subscribed`))
}
if retSpecialUse && info.mailbox != nil {
if info.mailbox != nil {
if info.mailbox.Archive {
flags = append(flags, bare(`\Archive`))
}
Expand Down
6 changes: 3 additions & 3 deletions imapserver/list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ func TestListBasic(t *testing.T) {
tc.xuntagged(ulist("Inbox"))

tc.last(tc.client.List("%"))
tc.xuntagged(ulist("Archive"), ulist("Drafts"), ulist("Inbox"), ulist("Junk"), ulist("Sent"), ulist("Trash"))
tc.xuntagged(ulist("Archive", `\Archive`), ulist("Drafts", `\Drafts`), ulist("Inbox"), ulist("Junk", `\Junk`), ulist("Sent", `\Sent`), ulist("Trash", `\Trash`))

tc.last(tc.client.List("*"))
tc.xuntagged(ulist("Archive"), ulist("Drafts"), ulist("Inbox"), ulist("Junk"), ulist("Sent"), ulist("Trash"))
tc.xuntagged(ulist("Archive", `\Archive`), ulist("Drafts", `\Drafts`), ulist("Inbox"), ulist("Junk", `\Junk`), ulist("Sent", `\Sent`), ulist("Trash", `\Trash`))

tc.last(tc.client.List("A*"))
tc.xuntagged(ulist("Archive"))
tc.xuntagged(ulist("Archive", `\Archive`))

tc.client.Create("Inbox/todo")

Expand Down

0 comments on commit 55febe3

Please sign in to comment.