From 7d7289bd51fab76907a65b63e4321efbf38c9072 Mon Sep 17 00:00:00 2001 From: iequidoo Date: Fri, 8 Mar 2024 02:14:27 -0300 Subject: [PATCH] feat: Start IMAP loop for sentbox only if it is configured (#5105) --- src/config.rs | 9 +++++++++ src/scheduler.rs | 5 +---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/config.rs b/src/config.rs index c124f08b0b..ad5492939f 100644 --- a/src/config.rs +++ b/src/config.rs @@ -475,6 +475,15 @@ impl Context { || self.get_config_bool(Config::OnlyFetchMvbox).await?) } + /// Returns true if sentbox ("Sent" folder) should be watched. + pub(crate) async fn should_watch_sentbox(&self) -> Result { + Ok(self.get_config_bool(Config::SentboxWatch).await? + && self + .get_config(Config::ConfiguredSentboxFolder) + .await? + .is_some()) + } + /// Gets configured "delete_server_after" value. /// /// `None` means never delete the message, `Some(0)` means delete diff --git a/src/scheduler.rs b/src/scheduler.rs index 948ac152bf..651d50b867 100644 --- a/src/scheduler.rs +++ b/src/scheduler.rs @@ -830,10 +830,7 @@ impl Scheduler { for (meaning, should_watch) in [ (FolderMeaning::Mvbox, ctx.should_watch_mvbox().await), - ( - FolderMeaning::Sent, - ctx.get_config_bool(Config::SentboxWatch).await, - ), + (FolderMeaning::Sent, ctx.should_watch_sentbox().await), ] { if should_watch? { let (conn_state, handlers) = ImapConnectionState::new(ctx).await?;