diff --git a/deltachat-ffi/deltachat.h b/deltachat-ffi/deltachat.h index 41e0cba3a4..65b41640e1 100644 --- a/deltachat-ffi/deltachat.h +++ b/deltachat-ffi/deltachat.h @@ -430,10 +430,6 @@ char* dc_get_blobdir (const dc_context_t* context); * 1=send a copy of outgoing messages to self (default). * Sending messages to self is needed for a proper multi-account setup, * however, on the other hand, may lead to unwanted notifications in non-delta clients. - * - `mvbox_move` = 1=detect chat messages, - * move them to the `DeltaChat` folder, - * and watch the `DeltaChat` folder for updates (default), - * 0=do not move chat-messages * - `only_fetch_mvbox` = 1=Do not fetch messages from folders other than the * `DeltaChat` folder. Messages will still be fetched from the * spam folder. diff --git a/deltachat-rpc-client/tests/test_multitransport.py b/deltachat-rpc-client/tests/test_multitransport.py index fda851b48f..f9cd8c6186 100644 --- a/deltachat-rpc-client/tests/test_multitransport.py +++ b/deltachat-rpc-client/tests/test_multitransport.py @@ -31,27 +31,24 @@ def test_add_second_address(acfactory) -> None: account.delete_transport(second_addr) assert len(account.list_transports()) == 2 - # Enabling mvbox_move or only_fetch_mvbox + # Enabling only_fetch_mvbox # is not allowed when multi-transport is enabled. - for option in ["mvbox_move", "only_fetch_mvbox"]: - with pytest.raises(JsonRpcError): - account.set_config(option, "1") + with pytest.raises(JsonRpcError): + account.set_config("only_fetch_mvbox", "1") with pytest.raises(JsonRpcError): account.set_config("show_emails", "0") -@pytest.mark.parametrize("key", ["mvbox_move", "only_fetch_mvbox"]) -def test_no_second_transport_with_mvbox(acfactory, key) -> None: +def test_no_second_transport_with_mvbox(acfactory) -> None: """Test that second transport cannot be configured if mvbox is used.""" account = acfactory.new_configured_account() assert len(account.list_transports()) == 1 - assert account.get_config("mvbox_move") == "0" assert account.get_config("only_fetch_mvbox") == "0" qr = acfactory.get_account_qr() - account.set_config(key, "1") + account.set_config("only_fetch_mvbox", "1") with pytest.raises(JsonRpcError): account.add_transport_from_qr(qr) @@ -120,30 +117,6 @@ def test_change_address(acfactory) -> None: assert sender_addr2 == new_alice_addr -@pytest.mark.parametrize("is_chatmail", ["0", "1"]) -def test_mvbox_move_first_transport(acfactory, is_chatmail) -> None: - """Test that mvbox_move is disabled by default even for non-chatmail accounts. - Disabling mvbox_move is required to be able to setup a second transport. - """ - account = acfactory.get_unconfigured_account() - - account.set_config("fix_is_chatmail", "1") - account.set_config("is_chatmail", is_chatmail) - - # The default value when the setting is unset is "1". - # This is not changed for compatibility with old databases - # imported from backups. - assert account.get_config("mvbox_move") == "1" - - qr = acfactory.get_account_qr() - account.add_transport_from_qr(qr) - - # Once the first transport is set up, - # mvbox_move is disabled. - assert account.get_config("mvbox_move") == "0" - assert account.get_config("is_chatmail") == is_chatmail - - def test_reconfigure_transport(acfactory) -> None: """Test that reconfiguring the transport works even if settings not supported for multi-transport diff --git a/python/src/deltachat/testplugin.py b/python/src/deltachat/testplugin.py index e658789ef2..d9b64a8b9b 100644 --- a/python/src/deltachat/testplugin.py +++ b/python/src/deltachat/testplugin.py @@ -522,7 +522,6 @@ def prepare_account_from_liveconfig(self, configdict) -> Account: ac = self.get_unconfigured_account() assert "addr" in configdict and "mail_pw" in configdict, configdict configdict.setdefault("bcc_self", False) - configdict.setdefault("mvbox_move", False) configdict.setdefault("sync_msgs", False) configdict.setdefault("delete_server_after", 0) ac.update_config(configdict) diff --git a/python/tests/test_3_offline.py b/python/tests/test_3_offline.py index 34ab1cc2da..3ffc52830a 100644 --- a/python/tests/test_3_offline.py +++ b/python/tests/test_3_offline.py @@ -52,19 +52,19 @@ def test_wrong_config_keys(self, acfactory): def test_set_config_int_conversion(self, acfactory): ac1 = acfactory.get_unconfigured_account() - ac1.set_config("mvbox_move", False) - assert ac1.get_config("mvbox_move") == "0" - ac1.set_config("mvbox_move", True) - assert ac1.get_config("mvbox_move") == "1" - ac1.set_config("mvbox_move", 0) - assert ac1.get_config("mvbox_move") == "0" - ac1.set_config("mvbox_move", 1) - assert ac1.get_config("mvbox_move") == "1" + ac1.set_config("bcc_self", False) + assert ac1.get_config("bcc_self") == "0" + ac1.set_config("bcc_self", True) + assert ac1.get_config("bcc_self") == "1" + ac1.set_config("bcc_self", 0) + assert ac1.get_config("bcc_self") == "0" + ac1.set_config("bcc_self", 1) + assert ac1.get_config("bcc_self") == "1" def test_update_config(self, acfactory): ac1 = acfactory.get_unconfigured_account() - ac1.update_config({"mvbox_move": False}) - assert ac1.get_config("mvbox_move") == "0" + ac1.update_config({"bcc_self": True}) + assert ac1.get_config("bcc_self") == "1" def test_has_bccself(self, acfactory): ac1 = acfactory.get_unconfigured_account() diff --git a/src/config.rs b/src/config.rs index 6a377754f7..19d2908ead 100644 --- a/src/config.rs +++ b/src/config.rs @@ -155,11 +155,6 @@ pub enum Config { #[strum(props(default = "1"))] MdnsEnabled, - /// 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. /// /// This will not entirely disable other folders, e.g. the spam folder will also still @@ -467,7 +462,6 @@ impl Config { self, Self::Displayname | Self::MdnsEnabled - | Self::MvboxMove | Self::ShowEmails | Self::Selfavatar | Self::Selfstatus, @@ -476,10 +470,7 @@ impl Config { /// Whether the config option needs an IO scheduler restart to take effect. pub(crate) fn needs_io_restart(&self) -> bool { - matches!( - self, - Config::MvboxMove | Config::OnlyFetchMvbox | Config::ConfiguredAddr - ) + matches!(self, Config::OnlyFetchMvbox | Config::ConfiguredAddr) } } @@ -597,9 +588,7 @@ impl Context { /// 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? - || self.get_config_bool(Config::OnlyFetchMvbox).await? - || !self.get_config_bool(Config::IsChatmail).await?) + self.get_config_bool(Config::OnlyFetchMvbox).await } /// Returns true if sync messages should be sent. @@ -683,7 +672,6 @@ impl Context { | Config::ProxyEnabled | Config::BccSelf | Config::MdnsEnabled - | Config::MvboxMove | Config::OnlyFetchMvbox | Config::Configured | Config::Bot @@ -708,12 +696,7 @@ impl Context { Self::check_config(key, value)?; let n_transports = self.count_transports().await?; - if n_transports > 1 - && matches!( - key, - Config::MvboxMove | Config::OnlyFetchMvbox | Config::ShowEmails - ) - { + if n_transports > 1 && matches!(key, Config::OnlyFetchMvbox | Config::ShowEmails) { bail!("Cannot reconfigure {key} when multiple transports are configured"); } @@ -795,12 +778,6 @@ impl Context { .set_raw_config(key.as_ref(), value.map(|s| s.to_lowercase()).as_deref()) .await?; } - Config::MvboxMove => { - self.sql.set_raw_config(key.as_ref(), value).await?; - self.sql - .set_raw_config(constants::DC_FOLDERS_CONFIGURED_KEY, None) - .await?; - } Config::ConfiguredAddr => { let Some(addr) = value else { bail!("Cannot unset configured_addr"); diff --git a/src/config/config_tests.rs b/src/config/config_tests.rs index 9a1a8f2c55..0952ae8949 100644 --- a/src/config/config_tests.rs +++ b/src/config/config_tests.rs @@ -196,11 +196,11 @@ async fn test_sync() -> Result<()> { sync(&alice0, &alice1).await; assert_eq!(alice1.get_config_bool(Config::MdnsEnabled).await?, false); - for key in [Config::ShowEmails, Config::MvboxMove] { - let val = alice0.get_config_bool(key).await?; - alice0.set_config_bool(key, !val).await?; + { + let val = alice0.get_config_bool(Config::ShowEmails).await?; + alice0.set_config_bool(Config::ShowEmails, !val).await?; sync(&alice0, &alice1).await; - assert_eq!(alice1.get_config_bool(key).await?, !val); + assert_eq!(alice1.get_config_bool(Config::ShowEmails).await?, !val); } // `Config::SyncMsgs` mustn't be synced. diff --git a/src/configure.rs b/src/configure.rs index a3137be246..fc98b74f31 100644 --- a/src/configure.rs +++ b/src/configure.rs @@ -281,11 +281,6 @@ impl Context { "To use additional relays, disable the legacy option \"Settings / Advanced / Only Fetch from DeltaChat Folder\"." ); } - if self.get_config(Config::MvboxMove).await?.as_deref() != Some("0") { - bail!( - "To use additional relays, disable the legacy option \"Settings / Advanced / Move automatically to DeltaChat Folder\"." - ); - } if self.get_config(Config::ShowEmails).await?.as_deref() != Some("2") { bail!( "To use additional relays, set the legacy option \"Settings / Advanced / Show Classic Emails\" to \"All\"." diff --git a/src/context.rs b/src/context.rs index 22b12bafaf..d3b65203a8 100644 --- a/src/context.rs +++ b/src/context.rs @@ -864,7 +864,6 @@ impl Context { Err(err) => format!(""), }; - let mvbox_move = self.get_config_int(Config::MvboxMove).await?; let only_fetch_mvbox = self.get_config_int(Config::OnlyFetchMvbox).await?; let folders_configured = self .sql @@ -956,7 +955,6 @@ impl Context { .await? .to_string(), ); - res.insert("mvbox_move", mvbox_move.to_string()); res.insert("only_fetch_mvbox", only_fetch_mvbox.to_string()); res.insert( constants::DC_FOLDERS_CONFIGURED_KEY, diff --git a/src/imap.rs b/src/imap.rs index 4365cb6a28..84f0c12aea 100644 --- a/src/imap.rs +++ b/src/imap.rs @@ -1667,43 +1667,6 @@ impl Session { } Ok(()) } - - /// Attempts to configure mvbox. - /// - /// Tries to find any folder examining `folders` in the order they go. - /// This method does not use LIST command to ensure that - /// configuration works even if mailbox lookup is forbidden via Access Control List (see - /// ). - /// - /// Returns first found folder name. - async fn configure_mvbox<'a>( - &mut self, - context: &Context, - folders: &[&'a str], - ) -> Result> { - // Close currently selected folder if needed. - // We are going to select folders using low-level EXAMINE operations below. - self.maybe_close_folder(context).await?; - - for folder in folders { - info!(context, "Looking for MVBOX-folder \"{}\"...", &folder); - let res = self.examine(&folder).await; - if res.is_ok() { - info!( - context, - "MVBOX-folder {:?} successfully selected, using it.", &folder - ); - self.close().await?; - // Before moving emails to the mvbox we need to remember its UIDVALIDITY, otherwise - // emails moved before that wouldn't be fetched but considered "old" instead. - let folder_exists = self.select_with_uidvalidity(context, folder).await?; - ensure!(folder_exists, "No MVBOX folder {:?}??", &folder); - return Ok(Some(folder)); - } - } - - Ok(None) - } } impl Imap { @@ -1716,23 +1679,11 @@ impl Imap { .list(Some(""), Some("*")) .await .context("list_folders failed")?; - let mut delimiter = ".".to_string(); - let mut delimiter_is_default = true; let mut folder_configs = BTreeMap::new(); while let Some(folder) = folders.try_next().await? { info!(context, "Scanning folder: {:?}", folder); - // Update the delimiter iff there is a different one, but only once. - if let Some(d) = folder.delimiter() - && delimiter_is_default - && !d.is_empty() - && delimiter != d - { - delimiter = d.to_string(); - delimiter_is_default = false; - } - let folder_meaning = get_folder_meaning_by_attrs(folder.attributes()); let folder_name_meaning = get_folder_meaning_by_name(folder.name()); if let Some(config) = folder_meaning.to_config() { @@ -1747,23 +1698,9 @@ impl Imap { } drop(folders); - info!(context, "Using \"{}\" as folder-delimiter.", delimiter); - - let fallback_folder = format!("INBOX{delimiter}DeltaChat"); - let mvbox_folder = session - .configure_mvbox(context, &["DeltaChat", &fallback_folder]) - .await - .context("failed to configure mvbox")?; - context .set_config_internal(Config::ConfiguredInboxFolder, Some("INBOX")) .await?; - if let Some(mvbox_folder) = mvbox_folder { - info!(context, "Setting MVBOX FOLDER TO {}", &mvbox_folder); - context - .set_config_internal(Config::ConfiguredMvboxFolder, Some(mvbox_folder)) - .await?; - } for (config, name) in folder_configs { context.set_config_internal(config, Some(&name)).await?; } @@ -1911,15 +1848,7 @@ async fn spam_target_folder_cfg( return Ok(None); } - if needs_move_to_mvbox(context, headers).await? - // If OnlyFetchMvbox is set, we don't want to move the message to - // the inbox where we wouldn't fetch it again: - || context.get_config_bool(Config::OnlyFetchMvbox).await? - { - Ok(Some(Config::ConfiguredMvboxFolder)) - } else { - Ok(Some(Config::ConfiguredInboxFolder)) - } + Ok(Some(Config::ConfiguredInboxFolder)) } /// Returns `ConfiguredInboxFolder` or `ConfiguredMvboxFolder` if @@ -1936,10 +1865,6 @@ pub async fn target_folder_cfg( if folder_meaning == FolderMeaning::Spam { spam_target_folder_cfg(context, headers).await - } else if folder_meaning == FolderMeaning::Inbox - && needs_move_to_mvbox(context, headers).await? - { - Ok(Some(Config::ConfiguredMvboxFolder)) } else { Ok(None) } @@ -1960,36 +1885,6 @@ pub async fn target_folder( } } -async fn needs_move_to_mvbox( - context: &Context, - headers: &[mailparse::MailHeader<'_>], -) -> Result { - let has_chat_version = headers.get_header_value(HeaderDef::ChatVersion).is_some(); - if !context.get_config_bool(Config::MvboxMove).await? { - return Ok(false); - } - - if headers - .get_header_value(HeaderDef::AutocryptSetupMessage) - .is_some() - { - // do not move setup messages; - // there may be a non-delta device that wants to handle it - return Ok(false); - } - - if has_chat_version { - Ok(true) - } else if let Some(parent) = get_prefetch_parent_message(context, headers).await? { - match parent.is_dc_message { - MessengerMessage::No => Ok(false), - MessengerMessage::Yes | MessengerMessage::Reply => Ok(true), - } - } else { - Ok(false) - } -} - /// 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, diff --git a/src/imap/imap_tests.rs b/src/imap/imap_tests.rs index 4ba3142133..ed1577696a 100644 --- a/src/imap/imap_tests.rs +++ b/src/imap/imap_tests.rs @@ -100,7 +100,6 @@ fn test_build_sequence_sets() { async fn check_target_folder_combination( folder: &str, - mvbox_move: bool, chat_msg: bool, expected_destination: &str, accepted_chat: bool, @@ -108,16 +107,13 @@ async fn check_target_folder_combination( setupmessage: bool, ) -> Result<()> { println!( - "Testing: For folder {folder}, mvbox_move {mvbox_move}, chat_msg {chat_msg}, accepted {accepted_chat}, outgoing {outgoing}, setupmessage {setupmessage}" + "Testing: For folder {folder}, chat_msg {chat_msg}, accepted {accepted_chat}, outgoing {outgoing}, setupmessage {setupmessage}" ); let t = TestContext::new_alice().await; t.ctx .set_config(Config::ConfiguredMvboxFolder, Some("DeltaChat")) .await?; - t.ctx - .set_config(Config::MvboxMove, Some(if mvbox_move { "1" } else { "0" })) - .await?; if accepted_chat { let contact_id = Contact::create(&t.ctx, "", "bob@example.net").await?; @@ -164,42 +160,33 @@ async fn check_target_folder_combination( assert_eq!( expected, actual.as_deref(), - "For folder {folder}, mvbox_move {mvbox_move}, chat_msg {chat_msg}, accepted {accepted_chat}, outgoing {outgoing}, setupmessage {setupmessage}: expected {expected:?}, got {actual:?}" + "For folder {folder}, chat_msg {chat_msg}, accepted {accepted_chat}, outgoing {outgoing}, setupmessage {setupmessage}: expected {expected:?}, got {actual:?}" ); Ok(()) } // chat_msg means that the message was sent by Delta Chat -// The tuples are (folder, mvbox_move, chat_msg, expected_destination) -const COMBINATIONS_ACCEPTED_CHAT: &[(&str, bool, bool, &str)] = &[ - ("INBOX", false, false, "INBOX"), - ("INBOX", false, true, "INBOX"), - ("INBOX", true, false, "INBOX"), - ("INBOX", true, true, "DeltaChat"), - ("Spam", false, false, "INBOX"), // Move classical emails in accepted chats from Spam to Inbox, not 100% sure on this, we could also just never move non-chat-msgs - ("Spam", false, true, "INBOX"), - ("Spam", true, false, "INBOX"), // Move classical emails in accepted chats from Spam to Inbox, not 100% sure on this, we could also just never move non-chat-msgs - ("Spam", true, true, "DeltaChat"), +// The tuples are (folder, chat_msg, expected_destination) +const COMBINATIONS_ACCEPTED_CHAT: &[(&str, bool, &str)] = &[ + ("INBOX", false, "INBOX"), + ("INBOX", true, "INBOX"), + ("Spam", false, "INBOX"), // Move classical emails in accepted chats from Spam to Inbox, not 100% sure on this, we could also just never move non-chat-msgs + ("Spam", true, "INBOX"), ]; // These are the same as above, but non-chat messages in Spam stay in Spam -const COMBINATIONS_REQUEST: &[(&str, bool, bool, &str)] = &[ - ("INBOX", false, false, "INBOX"), - ("INBOX", false, true, "INBOX"), - ("INBOX", true, false, "INBOX"), - ("INBOX", true, true, "DeltaChat"), - ("Spam", false, false, "Spam"), - ("Spam", false, true, "INBOX"), - ("Spam", true, false, "Spam"), - ("Spam", true, true, "DeltaChat"), +const COMBINATIONS_REQUEST: &[(&str, bool, &str)] = &[ + ("INBOX", false, "INBOX"), + ("INBOX", true, "INBOX"), + ("Spam", false, "Spam"), + ("Spam", true, "INBOX"), ]; #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_target_folder_incoming_accepted() -> Result<()> { - for (folder, mvbox_move, chat_msg, expected_destination) in COMBINATIONS_ACCEPTED_CHAT { + for (folder, chat_msg, expected_destination) in COMBINATIONS_ACCEPTED_CHAT { check_target_folder_combination( folder, - *mvbox_move, *chat_msg, expected_destination, true, @@ -213,10 +200,9 @@ async fn test_target_folder_incoming_accepted() -> Result<()> { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_target_folder_incoming_request() -> Result<()> { - for (folder, mvbox_move, chat_msg, expected_destination) in COMBINATIONS_REQUEST { + for (folder, chat_msg, expected_destination) in COMBINATIONS_REQUEST { check_target_folder_combination( folder, - *mvbox_move, *chat_msg, expected_destination, false, @@ -231,17 +217,9 @@ async fn test_target_folder_incoming_request() -> Result<()> { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_target_folder_outgoing() -> Result<()> { // 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?; + for (folder, chat_msg, expected_destination) in COMBINATIONS_ACCEPTED_CHAT { + check_target_folder_combination(folder, *chat_msg, expected_destination, true, true, false) + .await?; } Ok(()) } @@ -249,10 +227,9 @@ async fn test_target_folder_outgoing() -> Result<()> { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_target_folder_setupmsg() -> Result<()> { // Test setupmessages - for (folder, mvbox_move, chat_msg, _expected_destination) in COMBINATIONS_ACCEPTED_CHAT { + for (folder, chat_msg, _expected_destination) in COMBINATIONS_ACCEPTED_CHAT { check_target_folder_combination( folder, - *mvbox_move, *chat_msg, if folder == &"Spam" { "INBOX" } else { folder }, // Never move setup messages, except if they are in "Spam" false, diff --git a/src/scheduler.rs b/src/scheduler.rs index b69d360e36..dfe9eb0bf2 100644 --- a/src/scheduler.rs +++ b/src/scheduler.rs @@ -211,25 +211,19 @@ impl SchedulerState { /// Indicate that the network likely has come back. pub(crate) async fn maybe_network(&self) { let inner = self.inner.read().await; - let (inboxes, oboxes) = match *inner { + let inboxes = match *inner { InnerSchedulerState::Started(ref scheduler) => { scheduler.maybe_network(); - let inboxes = scheduler + scheduler .inboxes .iter() .map(|b| b.conn_state.state.connectivity.clone()) - .collect::>(); - let oboxes = scheduler - .oboxes - .iter() - .map(|b| b.conn_state.state.connectivity.clone()) - .collect::>(); - (inboxes, oboxes) + .collect::>() } _ => return, }; drop(inner); - connectivity::idle_interrupted(inboxes, oboxes); + connectivity::idle_interrupted(inboxes); } /// Indicate that the network likely is lost. @@ -330,8 +324,6 @@ struct SchedBox { pub(crate) struct Scheduler { /// Inboxes, one per transport. inboxes: Vec, - /// Optional boxes -- mvbox. - oboxes: Vec, smtp: SmtpConnectionState, smtp_handle: task::JoinHandle<()>, ephemeral_handle: task::JoinHandle<()>, @@ -479,7 +471,12 @@ async fn inbox_fetch_idle(ctx: &Context, imap: &mut Imap, mut session: Session) .await .context("Failed to register push token")?; - let session = fetch_idle(ctx, imap, session, FolderMeaning::Inbox).await?; + let folder_meaning = if ctx.get_config_bool(Config::OnlyFetchMvbox).await? { + FolderMeaning::Mvbox + } else { + FolderMeaning::Inbox + }; + let session = fetch_idle(ctx, imap, session, folder_meaning).await?; Ok(session) } @@ -504,12 +501,10 @@ async fn fetch_idle( bail!("Cannot fetch folder {folder_meaning} because it is not configured"); }; - if folder_config == Config::ConfiguredInboxFolder { - session - .store_seen_flags_on_imap(ctx) - .await - .context("store_seen_flags_on_imap")?; - } + session + .store_seen_flags_on_imap(ctx) + .await + .context("store_seen_flags_on_imap")?; // Fetch the watched folder. connection @@ -579,73 +574,6 @@ async fn fetch_idle( Ok(session) } -/// Simplified IMAP loop to watch non-inbox folders. -async fn simple_imap_loop( - ctx: Context, - started: oneshot::Sender<()>, - inbox_handlers: ImapConnectionHandlers, - folder_meaning: FolderMeaning, -) { - use futures::future::FutureExt; - - info!(ctx, "Starting simple loop for {folder_meaning}."); - let ImapConnectionHandlers { - mut connection, - stop_token, - } = inbox_handlers; - - let ctx1 = ctx.clone(); - - let fut = async move { - let ctx = ctx1; - if let Err(()) = started.send(()) { - warn!( - ctx, - "Simple imap loop for {folder_meaning}, missing started receiver." - ); - return; - } - - let mut old_session: Option = None; - loop { - let session = if let Some(session) = old_session.take() { - session - } else { - info!(ctx, "Preparing new IMAP session for {folder_meaning}."); - match connection.prepare(&ctx).await { - Err(err) => { - warn!( - ctx, - "Failed to prepare {folder_meaning} connection: {err:#}." - ); - continue; - } - Ok(session) => session, - } - }; - - match fetch_idle(&ctx, &mut connection, session, folder_meaning).await { - Err(err) => warn!(ctx, "Failed fetch_idle: {err:#}"), - Ok(session) => { - info!( - ctx, - "IMAP loop iteration for {folder_meaning} finished, keeping the session" - ); - old_session = Some(session); - } - } - } - }; - - stop_token - .cancelled() - .map(|_| { - info!(ctx, "Shutting down IMAP loop for {folder_meaning}."); - }) - .race(fut) - .await; -} - async fn smtp_loop( ctx: Context, started: oneshot::Sender<()>, @@ -748,7 +676,6 @@ impl Scheduler { let (location_interrupt_send, location_interrupt_recv) = channel::bounded(1); let mut inboxes = Vec::new(); - let mut oboxes = Vec::new(); let mut start_recvs = Vec::new(); for (transport_id, configured_login_param) in ConfiguredLoginParam::load_all(ctx).await? { @@ -768,22 +695,6 @@ impl Scheduler { }; inboxes.push(inbox); start_recvs.push(inbox_start_recv); - - if ctx.should_watch_mvbox().await? { - let (conn_state, handlers) = - ImapConnectionState::new(ctx, transport_id, configured_login_param).await?; - let (start_send, start_recv) = oneshot::channel(); - let ctx = ctx.clone(); - let meaning = FolderMeaning::Mvbox; - let handle = task::spawn(simple_imap_loop(ctx, start_send, handlers, meaning)); - oboxes.push(SchedBox { - addr, - meaning, - conn_state, - handle, - }); - start_recvs.push(start_recv); - } } let smtp_handle = { @@ -810,7 +721,6 @@ impl Scheduler { let res = Self { inboxes, - oboxes, smtp, smtp_handle, ephemeral_handle, @@ -830,7 +740,7 @@ impl Scheduler { } fn boxes(&self) -> impl Iterator { - self.inboxes.iter().chain(self.oboxes.iter()) + self.inboxes.iter() } fn maybe_network(&self) { @@ -884,7 +794,7 @@ impl Scheduler { let timeout_duration = std::time::Duration::from_secs(30); let tracker = TaskTracker::new(); - for b in self.inboxes.into_iter().chain(self.oboxes.into_iter()) { + for b in self.inboxes { let context = context.clone(); tracker.spawn(async move { tokio::time::timeout(timeout_duration, b.handle) diff --git a/src/scheduler/connectivity.rs b/src/scheduler/connectivity.rs index 78cd8f6c9a..8e4bd0cb82 100644 --- a/src/scheduler/connectivity.rs +++ b/src/scheduler/connectivity.rs @@ -201,7 +201,7 @@ impl ConnectivityStore { /// Set all folder states to InterruptingIdle in case they were `Idle` before. /// Called during `dc_maybe_network()` to make sure that `all_work_done()` /// returns false immediately after `dc_maybe_network()`. -pub(crate) fn idle_interrupted(inboxes: Vec, oboxes: Vec) { +pub(crate) fn idle_interrupted(inboxes: Vec) { for inbox in inboxes { let mut connectivity_lock = inbox.0.lock(); // For the inbox, we also have to set the connectivity to InterruptingIdle if it was @@ -216,12 +216,6 @@ pub(crate) fn idle_interrupted(inboxes: Vec, oboxes: Vec