From 500e2d62a0aee17d3635165acf0957ae1d64a829 Mon Sep 17 00:00:00 2001 From: bjoern Date: Tue, 8 Mar 2022 11:29:45 +0100 Subject: [PATCH] remove sentbox_move (#3111) * remove SentboxMove * adapt python test to removed sendbox_move option * update CHANGELOG --- CHANGELOG.md | 2 + python/tests/test_account.py | 3 +- src/config.rs | 3 -- src/context.rs | 2 - src/imap.rs | 84 ++++++------------------------------ 5 files changed, 16 insertions(+), 78 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 49dc0c33b..0ed7fcc3a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,8 @@ - add more SMTP logging #3093 - place common headers like `From:` before the large `Autocrypt:` header #3079 - keep track of securejoin joiner status in database to survive restarts #2920 +- remove never used `SentboxMove` option #3111 + ## 1.76.0 diff --git a/python/tests/test_account.py b/python/tests/test_account.py index 323d7d0e8..dd15f03eb 100644 --- a/python/tests/test_account.py +++ b/python/tests/test_account.py @@ -2732,7 +2732,6 @@ class TestOnlineAccount: assert ac.get_config("configured_mvbox_folder") ac1 = acfactory.get_online_configuring_account(move=mvbox_move) - ac1.set_config("sentbox_move", "1") ac2 = acfactory.get_online_configuring_account() acfactory.wait_configure(ac1) @@ -2752,7 +2751,7 @@ class TestOnlineAccount: if mvbox_move: ac1.direct_imap.select_config_folder("mvbox") else: - ac1.direct_imap.select_config_folder("sentbox") + ac1.direct_imap.select_folder("INBOX") ac1.direct_imap.idle_start() lp.sec("send out message with bcc to ourselves") diff --git a/src/config.rs b/src/config.rs index e73a48390..e21cae720 100644 --- a/src/config.rs +++ b/src/config.rs @@ -71,9 +71,6 @@ pub enum Config { #[strum(props(default = "1"))] MvboxMove, - #[strum(props(default = "0"))] - SentboxMove, // If `MvboxMove` is true, this config is ignored. Currently only used in tests. - /// Watch for new messages in the "Mvbox" (aka DeltaChat folder) only. /// /// This will not entirely disable other folders, e.g. the spam folder will also still diff --git a/src/context.rs b/src/context.rs index b8a70bfb0..bac653ac1 100644 --- a/src/context.rs +++ b/src/context.rs @@ -354,7 +354,6 @@ impl Context { let sentbox_watch = self.get_config_int(Config::SentboxWatch).await?; let mvbox_move = self.get_config_int(Config::MvboxMove).await?; - let sentbox_move = self.get_config_int(Config::SentboxMove).await?; let only_fetch_mvbox = self.get_config_int(Config::OnlyFetchMvbox).await?; let folders_configured = self .sql @@ -419,7 +418,6 @@ impl Context { ); res.insert("sentbox_watch", sentbox_watch.to_string()); res.insert("mvbox_move", mvbox_move.to_string()); - res.insert("sentbox_move", sentbox_move.to_string()); res.insert("only_fetch_mvbox", only_fetch_mvbox.to_string()); res.insert("folders_configured", folders_configured.to_string()); res.insert("configured_sentbox_folder", configured_sentbox_folder); diff --git a/src/imap.rs b/src/imap.rs index 1cadeac9b..f483a50be 100644 --- a/src/imap.rs +++ b/src/imap.rs @@ -1654,7 +1654,6 @@ async fn should_move_out_of_spam( /// messages from the Spam folder, the message will be ignored. async fn spam_target_folder( context: &Context, - folder: &str, headers: &[mailparse::MailHeader<'_>], ) -> Result> { if !should_move_out_of_spam(context, headers).await? { @@ -1667,8 +1666,6 @@ async fn spam_target_folder( || context.get_config_bool(Config::OnlyFetchMvbox).await? { Ok(Some(Config::ConfiguredMvboxFolder)) - } else if needs_move_to_sentbox(context, folder, headers).await? { - Ok(Some(Config::ConfiguredSentboxFolder)) } else { Ok(Some(Config::ConfiguredInboxFolder)) } @@ -1686,11 +1683,9 @@ pub async fn target_folder( } if context.is_spam_folder(folder).await? { - spam_target_folder(context, folder, headers).await + spam_target_folder(context, headers).await } else if needs_move_to_mvbox(context, headers).await? { Ok(Some(Config::ConfiguredMvboxFolder)) - } else if needs_move_to_sentbox(context, folder, headers).await? { - Ok(Some(Config::ConfiguredSentboxFolder)) } else { Ok(None) } @@ -1725,44 +1720,6 @@ async fn needs_move_to_mvbox( } } -async fn prefetch_is_outgoing( - context: &Context, - headers: &[mailparse::MailHeader<'_>], -) -> Result { - let from_address_list = &mimeparser::get_from(headers); - - // Only looking at the first address in the `From:` field. - if let Some(info) = from_address_list.first() { - if context.is_self_addr(&info.addr).await? { - Ok(true) - } else { - Ok(false) - } - } else { - Ok(false) - } -} - -async fn needs_move_to_sentbox( - context: &Context, - folder: &str, - headers: &[mailparse::MailHeader<'_>], -) -> Result { - let needs_move = context.get_config_bool(Config::SentboxMove).await? - && context - .get_config(Config::ConfiguredSentboxFolder) - .await? - .is_some() - && context.is_inbox(folder).await? - && headers.get_header_value(HeaderDef::ChatVersion).is_some() - && headers - .get_header_value(HeaderDef::AutocryptSetupMessage) - .is_none() - && prefetch_is_outgoing(context, headers).await?; - - Ok(needs_move) -} - /// Try to get the folder meaning by the name of the folder only used if the server does not support XLIST. // TODO: lots languages missing - maybe there is a list somewhere on other MUAs? // however, if we fail to find out the sent-folder, @@ -2330,7 +2287,6 @@ mod tests { accepted_chat: bool, outgoing: bool, setupmessage: bool, - sentbox_move: bool, ) -> Result<()> { println!("Testing: For folder {}, mvbox_move {}, chat_msg {}, accepted {}, outgoing {}, setupmessage {}", folder, mvbox_move, chat_msg, accepted_chat, outgoing, setupmessage); @@ -2349,9 +2305,6 @@ mod tests { .set_config(Config::MvboxMove, Some(if mvbox_move { "1" } else { "0" })) .await?; t.ctx.set_config(Config::ShowEmails, Some("2")).await?; - t.ctx - .set_config_bool(Config::SentboxMove, sentbox_move) - .await?; if accepted_chat { let contact_id = Contact::create(&t.ctx, "", "bob@example.net").await?; @@ -2443,7 +2396,6 @@ mod tests { true, false, false, - false, ) .await?; } @@ -2461,7 +2413,6 @@ mod tests { false, false, false, - false, ) .await?; } @@ -2470,26 +2421,18 @@ mod tests { #[async_std::test] async fn test_target_folder_outgoing() -> Result<()> { - for sentbox_move in &[true, false] { - // Test outgoing emails - for (folder, mvbox_move, chat_msg, mut expected_destination) in - COMBINATIONS_ACCEPTED_CHAT - { - if *folder == "INBOX" && !mvbox_move && *chat_msg && *sentbox_move { - expected_destination = "Sent" - } - check_target_folder_combination( - folder, - *mvbox_move, - *chat_msg, - expected_destination, - true, - true, - false, - *sentbox_move, - ) - .await?; - } + // Test outgoing emails + for (folder, mvbox_move, chat_msg, expected_destination) in COMBINATIONS_ACCEPTED_CHAT { + check_target_folder_combination( + folder, + *mvbox_move, + *chat_msg, + expected_destination, + true, + true, + false, + ) + .await?; } Ok(()) } @@ -2506,7 +2449,6 @@ mod tests { false, true, true, - false, ) .await?; }