Skip to content

Commit

Permalink
fix(GODT-1776): enable SPECIAL-USE mailbox attributes.
Browse files Browse the repository at this point in the history
  • Loading branch information
cuthix authored and jameshoulahan committed Oct 6, 2022
1 parent 634f8b9 commit 4783e96
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 1 deletion.
9 changes: 9 additions & 0 deletions imap/attributes.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,13 @@ const (
AttrNoInferiors = `\Noinferiors`
AttrMarked = `\Marked`
AttrUnmarked = `\Unmarked`

// Special Use attributes as defined in RFC-6154.
AttrAll = `\All`
AttrArchive = `\Archive`
AttrDrafts = `\Drafts`
AttrFlagged = `\Flagged`
AttrJunk = `\Junk`
AttrSent = `\Sent`
AttrTrash = `\Trash`
)
26 changes: 26 additions & 0 deletions tests/list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,3 +234,29 @@ func TestListWildcards(t *testing.T) {
c.OK(`tag`)
})
}

func TestListSpecialUseAttributes(t *testing.T) {
runOneToOneTestWithAuth(t, defaultServerOptions(t, withDelimiter(".")), func(c *testConnection, s *testSession) {
s.mailboxCreated("user", []string{"INBOX"})
s.mailboxCreatedWithAttributes("user", []string{"Koncepty"}, imap.NewFlagSet(imap.AttrDrafts))
s.mailboxCreatedWithAttributes("user", []string{"Odeslane"}, imap.NewFlagSet(imap.AttrSent))
s.mailboxCreatedWithAttributes("user", []string{"S hvezdickou"}, imap.NewFlagSet(imap.AttrFlagged))
s.mailboxCreatedWithAttributes("user", []string{"Archiv"}, imap.NewFlagSet(imap.AttrArchive))
s.mailboxCreatedWithAttributes("user", []string{"Spam"}, imap.NewFlagSet(imap.AttrJunk))
s.mailboxCreatedWithAttributes("user", []string{"Kos"}, imap.NewFlagSet(imap.AttrTrash))
s.mailboxCreatedWithAttributes("user", []string{"Vsechny zpravy"}, imap.NewFlagSet(imap.AttrAll))

c.C(`a list "" "*"`)
c.S(
`* LIST (\Unmarked) "." "INBOX"`,
`* LIST (\Drafts \Unmarked) "." "Koncepty"`,
`* LIST (\Sent \Unmarked) "." "Odeslane"`,
`* LIST (\Flagged \Unmarked) "." "S hvezdickou"`,
`* LIST (\Archive \Unmarked) "." "Archiv"`,
`* LIST (\Junk \Unmarked) "." "Spam"`,
`* LIST (\Trash \Unmarked) "." "Kos"`,
`* LIST (\All \Unmarked) "." "Vsechny zpravy"`,
)
c.OK(`a`)
})
}
6 changes: 5 additions & 1 deletion tests/session_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,18 @@ func (s *testSession) setLabelPrefix(user, prefix string) {
}

func (s *testSession) mailboxCreated(user string, name []string, withData ...string) imap.LabelID {
return s.mailboxCreatedWithAttributes(user, name, defaultAttributes, withData...)
}

func (s *testSession) mailboxCreatedWithAttributes(user string, name []string, attributes imap.FlagSet, withData ...string) imap.LabelID {
mboxID := imap.LabelID(utils.NewRandomLabelID())

require.NoError(s.tb, s.conns[s.userIDs[user]].MailboxCreated(imap.Mailbox{
ID: mboxID,
Name: name,
Flags: defaultFlags,
PermanentFlags: defaultPermanentFlags,
Attributes: defaultAttributes,
Attributes: attributes,
}))

for _, data := range withData {
Expand Down

0 comments on commit 4783e96

Please sign in to comment.