diff --git a/src/config.rs b/src/config.rs index d24d5bfcd..ff875d911 100644 --- a/src/config.rs +++ b/src/config.rs @@ -164,7 +164,6 @@ pub enum Config { /// True if chat messages should be moved to a separate folder. Auto-sent messages like sync /// ones are moved there anyway. - #[strum(props(default = "1"))] MvboxMove, /// Watch for new messages in the "Mvbox" (aka DeltaChat folder) only. @@ -596,9 +595,17 @@ impl Context { .unwrap_or_default()) } + /// Returns true if chat messages should be moved to the mvbox ("DeltaChat" folder). + pub(crate) async fn should_move_to_mvbox(&self) -> Result { + match self.get_config_bool_opt(Config::MvboxMove).await? { + Some(val) => Ok(val), + None => Ok(!self.get_config_bool(Config::IsChatmail).await?), + } + } + /// Returns true if movebox ("DeltaChat" folder) should be watched. pub(crate) async fn should_watch_mvbox(&self) -> Result { - Ok(self.get_config_bool(Config::MvboxMove).await? + Ok(self.should_move_to_mvbox().await? || self.get_config_bool(Config::OnlyFetchMvbox).await? || !self.get_config_bool(Config::IsChatmail).await?) } diff --git a/src/config/config_tests.rs b/src/config/config_tests.rs index c35e9a023..317bd3d11 100644 --- a/src/config/config_tests.rs +++ b/src/config/config_tests.rs @@ -185,6 +185,15 @@ async fn test_delete_server_after_default() -> Result<()> { Ok(()) } +#[tokio::test(flavor = "multi_thread", worker_threads = 2)] +async fn test_should_move_to_mvbox() -> Result<()> { + let alice = &TestContext::new_alice().await; + assert!(alice.should_move_to_mvbox().await?); + alice.set_config_bool(Config::IsChatmail, true).await?; + assert!(!alice.should_move_to_mvbox().await?); + Ok(()) +} + const SAVED_MESSAGES_DEDUPLICATED_FILE: &str = "969142cb84015bc135767bc2370934a.png"; #[tokio::test(flavor = "multi_thread", worker_threads = 2)] diff --git a/src/configure.rs b/src/configure.rs index 3ad54aa8e..154266c78 100644 --- a/src/configure.rs +++ b/src/configure.rs @@ -529,7 +529,6 @@ async fn configure(ctx: &Context, param: &EnteredLoginParam) -> Result session.is_chatmail(), true => context.get_config_bool(Config::IsChatmail).await?, }; - let create_mvbox = !is_chatmail || context.get_config_bool(Config::MvboxMove).await?; + let create_mvbox = context + .get_config_bool_opt(Config::MvboxMove) + .await? + .unwrap_or(!is_chatmail); self.configure_folders(context, &mut session, create_mvbox) .await?; } @@ -1784,7 +1787,7 @@ impl Imap { context .set_config_internal(Config::ConfiguredMvboxFolder, Some(mvbox_folder)) .await?; - } else if create_mvbox && context.config_exists(Config::MvboxMove).await? { + } else if context.get_config_bool_opt(Config::MvboxMove).await? == Some(true) { warn!(context, "Will retry configuring MVBOX on reconnect."); return Ok(()); } @@ -1997,7 +2000,7 @@ async fn needs_move_to_mvbox( } } } - if !context.get_config_bool(Config::MvboxMove).await? { + if !context.should_move_to_mvbox().await? { return Ok(false); }