diff options
author | Tim Culverhouse <tim@timculverhouse.com> | 2023-04-16 09:53:45 -0500 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2023-04-22 22:40:12 +0200 |
commit | 669431702f46eb58f893cbe722040de3792f6b03 (patch) | |
tree | 92899c33c7032d598092d3147bf6e8efbc3741e9 /worker/imap | |
parent | 5b0a98b8c936532fa5444b1cabf53d7c929d19c1 (diff) | |
download | aerc-669431702f46eb58f893cbe722040de3792f6b03.tar.gz |
directory: add IANA mailbox roles
Add IANA registered mailbox role, and a custom aerc role "query". This
will be used in subsequent commits which add the Role field to
templates, allowing users to style mailbox by IANA role, or style
notmuch queries differently than maildir dirs when using the notmuch
worker + maildir option.
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
Acked-by: Robin Jarry<robin@jarry.cc>
Diffstat (limited to 'worker/imap')
-rw-r--r-- | worker/imap/list.go | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/worker/imap/list.go b/worker/imap/list.go index 657779e5..41924d86 100644 --- a/worker/imap/list.go +++ b/worker/imap/list.go @@ -1,6 +1,8 @@ package imap import ( + "strings" + "github.com/emersion/go-imap" "git.sr.ht/~rjarry/aerc/log" @@ -21,11 +23,24 @@ func (imapw *IMAPWorker) handleListDirectories(msg *types.ListDirectories) { // no need to pass this to handlers if it can't be opened continue } + dir := &models.Directory{ + Name: mbox.Name, + } + for _, attr := range mbox.Attributes { + attr = strings.TrimPrefix(attr, "\\") + attr = strings.ToLower(attr) + role, ok := models.Roles[attr] + if !ok { + continue + } + dir.Role = role + } + if mbox.Name == "INBOX" { + dir.Role = models.InboxRole + } imapw.worker.PostMessage(&types.Directory{ Message: types.RespondTo(msg), - Dir: &models.Directory{ - Name: mbox.Name, - }, + Dir: dir, }, nil) } done <- nil |