diff --git a/deltachat-rpc-client/tests/test_multitransport.py b/deltachat-rpc-client/tests/test_multitransport.py index ae43c65ed..291dbc76a 100644 --- a/deltachat-rpc-client/tests/test_multitransport.py +++ b/deltachat-rpc-client/tests/test_multitransport.py @@ -225,6 +225,9 @@ def test_transport_synchronization(acfactory, log) -> None: log.section("ac1 changes the primary transport") ac1.set_config("configured_addr", transport3["addr"]) + # One event for updated `add_timestamp` of the new primary transport, + # one event for the `configured_addr` update. + ac1_clone.wait_for_event(EventType.TRANSPORTS_MODIFIED) ac1_clone.wait_for_event(EventType.TRANSPORTS_MODIFIED) [transport1, transport3] = ac1_clone.list_transports() assert ac1_clone.get_config("configured_addr") == addr3 diff --git a/src/config.rs b/src/config.rs index 09271b89b..f524efb64 100644 --- a/src/config.rs +++ b/src/config.rs @@ -19,7 +19,7 @@ use crate::log::LogExt; use crate::mimefactory::RECOMMENDED_FILE_SIZE; use crate::provider::Provider; use crate::sync::{self, Sync::*, SyncData}; -use crate::tools::get_abs_path; +use crate::tools::{get_abs_path, time}; use crate::transport::{ConfiguredLoginParam, add_pseudo_transport, send_sync_transports}; use crate::{constants, stats}; @@ -828,6 +828,22 @@ impl Context { (addr,), )?; + // Update the timestamp for the primary transport + // so it becomes the first in `get_all_self_addrs()` list + // and the list of relays distributed in the public key. + // This ensures that messages will be sent + // to the primary relay by the contacts + // and will be fetched in background_fetch() + // which only fetches from the primary transport. + transaction + .execute( + "UPDATE transports SET add_timestamp=? WHERE addr=?", + (time(), addr), + ) + .context( + "Failed to update add_timestamp for the new primary transport", + )?; + // Clean up SMTP and IMAP APPEND queue. // // The messages in the queue have a different