From f5cfbd32e6ebbe83ad7e84d048f1fbf2e51ca605 Mon Sep 17 00:00:00 2001 From: Manos Pitsidianakis Date: Tue, 20 Jun 2023 13:22:52 +0300 Subject: [PATCH] melib/imap: on set_flags, update {un,}seen sets in all mailboxes Some envelopes might be in several mailboxes, for example in Gmail's implementation of IMAP. --- melib/src/backends/imap.rs | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/melib/src/backends/imap.rs b/melib/src/backends/imap.rs index 6f09e871..eb76bc9d 100644 --- a/melib/src/backends/imap.rs +++ b/melib/src/backends/imap.rs @@ -793,12 +793,13 @@ impl MailBackend for ImapType { conn.read_response(&mut response, RequiredResponses::empty()) .await?; if set_seen { - let f = &uid_store.mailboxes.lock().await[&mailbox_hash]; - if let Ok(mut unseen) = f.unseen.lock() { - for env_hash in env_hashes.iter() { - unseen.remove(env_hash); - } - }; + for f in uid_store.mailboxes.lock().await.values() { + if let Ok(mut unseen) = f.unseen.lock() { + for env_hash in env_hashes.iter() { + unseen.remove(env_hash); + } + }; + } } } if flags.iter().any(|(_, b)| !*b) { @@ -858,12 +859,13 @@ impl MailBackend for ImapType { conn.read_response(&mut response, RequiredResponses::empty()) .await?; if set_unseen { - let f = &uid_store.mailboxes.lock().await[&mailbox_hash]; - if let Ok(mut unseen) = f.unseen.lock() { - for env_hash in env_hashes.iter() { - unseen.insert_new(env_hash); - } - }; + for f in uid_store.mailboxes.lock().await.values() { + if let Ok(mut unseen) = f.unseen.lock() { + for env_hash in env_hashes.iter() { + unseen.insert_new(env_hash); + } + }; + } } } Ok(())