Skip non selectable mailboxes in directory listing
If a MailboxInfo has the attribute \Noselect, it is not possible to use this name as a selectable mailbox. Therefore it should not be passed to the directory handlers. The issue pops up if one has a hierarchy like this: INBOX INBOX/lists/stuff INBOX/lists/otherStuff Even though lists is not a valid inbox (doesn't contain mail, only other maildirs) it will show up in the directory listing, when we iterate over the MailboxInfo. It does have the corresponding attribute set though and we can simply filter it out.
This commit is contained in:
parent
ee61c28e75
commit
61f1b229ec
1 changed files with 13 additions and 0 deletions
|
@ -12,6 +12,10 @@ func (imapw *IMAPWorker) handleListDirectories(msg *types.ListDirectories) {
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
for mbox := range mailboxes {
|
for mbox := range mailboxes {
|
||||||
|
if !canOpen(mbox) {
|
||||||
|
// no need to pass this to handlers if it can't be opened
|
||||||
|
continue
|
||||||
|
}
|
||||||
imapw.worker.PostMessage(&types.Directory{
|
imapw.worker.PostMessage(&types.Directory{
|
||||||
Message: types.RespondTo(msg),
|
Message: types.RespondTo(msg),
|
||||||
Name: mbox.Name,
|
Name: mbox.Name,
|
||||||
|
@ -30,3 +34,12 @@ func (imapw *IMAPWorker) handleListDirectories(msg *types.ListDirectories) {
|
||||||
&types.Done{types.RespondTo(msg)}, nil)
|
&types.Done{types.RespondTo(msg)}, nil)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func canOpen(mbox *imap.MailboxInfo) bool {
|
||||||
|
for _, attr := range mbox.Attributes {
|
||||||
|
if attr == imap.NoSelectAttr {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue