From 98949a4a722034d6e83311b6e9166865afa542de Mon Sep 17 00:00:00 2001 From: Manos Pitsidianakis Date: Fri, 18 Sep 2020 12:08:02 +0300 Subject: [PATCH] melib/imap: expand special mailbox detection cases --- melib/src/backends/imap.rs | 5 +++++ melib/src/backends/imap/protocol_parser.rs | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/melib/src/backends/imap.rs b/melib/src/backends/imap.rs index 39cc2e74..beda1507 100644 --- a/melib/src/backends/imap.rs +++ b/melib/src/backends/imap.rs @@ -1443,6 +1443,11 @@ impl ImapType { for l in lines { if let Ok(subscription) = protocol_parser::list_mailbox_result(&l).map(|(_, v)| v) { if let Some(f) = mailboxes.get_mut(&subscription.hash()) { + if f.special_usage() == SpecialUsageMailbox::Normal + && subscription.special_usage() != SpecialUsageMailbox::Normal + { + f.set_special_usage(subscription.special_usage())?; + } f.is_subscribed = true; } } else { diff --git a/melib/src/backends/imap/protocol_parser.rs b/melib/src/backends/imap/protocol_parser.rs index f467b96d..0aaf8bcf 100644 --- a/melib/src/backends/imap/protocol_parser.rs +++ b/melib/src/backends/imap/protocol_parser.rs @@ -425,9 +425,15 @@ pub fn list_mailbox_result(input: &[u8]) -> IResult<&[u8], ImapMailbox> { } else if p.eq_ignore_ascii_case(b"\\Sent") { let _ = f.set_special_usage(SpecialUsageMailbox::Sent); } else if p.eq_ignore_ascii_case(b"\\Junk") { + let _ = f.set_special_usage(SpecialUsageMailbox::Junk); + } else if p.eq_ignore_ascii_case(b"\\Trash") { let _ = f.set_special_usage(SpecialUsageMailbox::Trash); } else if p.eq_ignore_ascii_case(b"\\Drafts") { let _ = f.set_special_usage(SpecialUsageMailbox::Drafts); + } else if p.eq_ignore_ascii_case(b"\\Flagged") { + let _ = f.set_special_usage(SpecialUsageMailbox::Flagged); + } else if p.eq_ignore_ascii_case(b"\\Archive") { + let _ = f.set_special_usage(SpecialUsageMailbox::Archive); } } f.imap_path = path.to_string();