diff --git a/deltachat-jsonrpc/src/api.rs b/deltachat-jsonrpc/src/api.rs index a4102fc25..f48c949c1 100644 --- a/deltachat-jsonrpc/src/api.rs +++ b/deltachat-jsonrpc/src/api.rs @@ -439,7 +439,7 @@ impl CommandApi { /// Setup the credential config before calling this. /// /// Deprecated as of 2025-02; use `add_transport_from_qr()` - /// or `add_transport()` instead. + /// or `add_or_update_transport()` instead. async fn configure(&self, account_id: u32) -> Result<()> { let ctx = self.get_context(account_id).await?; ctx.stop_io().await; @@ -483,21 +483,30 @@ impl CommandApi { /// from a server encoded in a QR code. /// - [Self::list_transports()] to get a list of all configured transports. /// - [Self::delete_transport()] to remove a transport. - async fn add_transport(&self, account_id: u32, param: EnteredLoginParam) -> Result<()> { + async fn add_or_update_transport( + &self, + account_id: u32, + param: EnteredLoginParam, + ) -> Result<()> { let ctx = self.get_context(account_id).await?; - ctx.add_transport(¶m.try_into()?).await + ctx.add_or_update_transport(¶m.try_into()?).await + } + + /// Deprecated 2025-04. Alias for [Self::add_or_update_transport()]. + async fn add_transport(&self, account_id: u32, param: EnteredLoginParam) -> Result<()> { + self.add_or_update_transport(account_id, param).await } /// Adds a new email account as a transport /// using the server encoded in the QR code. - /// See [Self::add_transport]. + /// See [Self::add_or_update_transport]. async fn add_transport_from_qr(&self, account_id: u32, qr: String) -> Result<()> { let ctx = self.get_context(account_id).await?; ctx.add_transport_from_qr(&qr).await } /// Returns the list of all email accounts that are used as a transport in the current profile. - /// Use [Self::add_transport()] to add or change a transport + /// Use [Self::add_or_update_transport()] to add or change a transport /// and [Self::delete_transport()] to delete a transport. async fn list_transports(&self, account_id: u32) -> Result> { let ctx = self.get_context(account_id).await?; diff --git a/deltachat-rpc-client/src/deltachat_rpc_client/account.py b/deltachat-rpc-client/src/deltachat_rpc_client/account.py index c56198da2..1b9f67e12 100644 --- a/deltachat-rpc-client/src/deltachat_rpc_client/account.py +++ b/deltachat-rpc-client/src/deltachat_rpc_client/account.py @@ -111,9 +111,9 @@ class Account: yield self._rpc.configure.future(self.id) @futuremethod - def add_transport(self, params): + def add_or_update_transport(self, params): """Add a new transport.""" - yield self._rpc.add_transport.future(self.id, params) + yield self._rpc.add_or_update_transport.future(self.id, params) def bring_online(self): """Start I/O and wait until IMAP becomes IDLE.""" diff --git a/deltachat-rpc-client/src/deltachat_rpc_client/pytestplugin.py b/deltachat-rpc-client/src/deltachat_rpc_client/pytestplugin.py index bafa464b3..8acc4462e 100644 --- a/deltachat-rpc-client/src/deltachat_rpc_client/pytestplugin.py +++ b/deltachat-rpc-client/src/deltachat_rpc_client/pytestplugin.py @@ -34,7 +34,7 @@ class ACFactory: addr, password = self.get_credentials() account = self.get_unconfigured_account() params = {"addr": addr, "password": password} - yield account.add_transport.future(params) + yield account.add_or_update_transport.future(params) assert account.is_configured() return account diff --git a/deltachat-rpc-client/tests/test_account_events.py b/deltachat-rpc-client/tests/test_account_events.py index b321cc76d..c462f25f4 100644 --- a/deltachat-rpc-client/tests/test_account_events.py +++ b/deltachat-rpc-client/tests/test_account_events.py @@ -17,7 +17,7 @@ def test_event_on_configuration(acfactory: ACFactory) -> None: account = acfactory.get_unconfigured_account() account.clear_all_events() assert not account.is_configured() - future = account.add_transport.future({"addr": addr, "password": password}) + future = account.add_or_update_transport.future({"addr": addr, "password": password}) while True: event = account.wait_for_event() if event.kind == EventType.ACCOUNTS_ITEM_CHANGED: diff --git a/deltachat-rpc-client/tests/test_something.py b/deltachat-rpc-client/tests/test_something.py index 2d602da62..2c0b50868 100644 --- a/deltachat-rpc-client/tests/test_something.py +++ b/deltachat-rpc-client/tests/test_something.py @@ -63,7 +63,7 @@ def test_acfactory(acfactory) -> None: def test_configure_starttls(acfactory) -> None: addr, password = acfactory.get_credentials() account = acfactory.get_unconfigured_account() - account.add_transport( + account.add_or_update_transport( { "addr": addr, "password": password, @@ -80,7 +80,7 @@ def test_configure_ip(acfactory) -> None: ip_address = socket.gethostbyname(addr.rsplit("@")[-1]) with pytest.raises(JsonRpcError): - account.add_transport( + account.add_or_update_transport( { "addr": addr, "password": password, @@ -94,7 +94,7 @@ def test_configure_alternative_port(acfactory) -> None: """Test that configuration with alternative port 443 works.""" addr, password = acfactory.get_credentials() account = acfactory.get_unconfigured_account() - account.add_transport( + account.add_or_update_transport( { "addr": addr, "password": password, @@ -108,7 +108,7 @@ def test_configure_alternative_port(acfactory) -> None: def test_list_transports(acfactory) -> None: addr, password = acfactory.get_credentials() account = acfactory.get_unconfigured_account() - account.add_transport( + account.add_or_update_transport( { "addr": addr, "password": password, @@ -420,7 +420,7 @@ def test_wait_next_messages(acfactory) -> None: addr, password = acfactory.get_credentials() bot = acfactory.get_unconfigured_account() bot.set_config("bot", "1") - bot.add_transport({"addr": addr, "password": password}) + bot.add_or_update_transport({"addr": addr, "password": password}) assert bot.is_configured() # There are no old messages and the call returns immediately. @@ -603,7 +603,7 @@ def test_reactions_for_a_reordering_move(acfactory, direct_imap): addr, password = acfactory.get_credentials() ac2 = acfactory.get_unconfigured_account() - ac2.add_transport({"addr": addr, "password": password}) + ac2.add_or_update_transport({"addr": addr, "password": password}) ac2.set_config("mvbox_move", "1") assert ac2.is_configured() diff --git a/src/configure.rs b/src/configure.rs index 195fdff03..d0bbd03d1 100644 --- a/src/configure.rs +++ b/src/configure.rs @@ -69,7 +69,7 @@ impl Context { /// Configures this account with the currently provided parameters. /// /// Deprecated since 2025-02; use `add_transport_from_qr()` - /// or `add_transport()` instead. + /// or `add_or_update_transport()` instead. pub async fn configure(&self) -> Result<()> { let param = EnteredLoginParam::load(self).await?; @@ -105,7 +105,7 @@ impl Context { /// from a server encoded in a QR code. /// - [Self::list_transports()] to get a list of all configured transports. /// - [Self::delete_transport()] to remove a transport. - pub async fn add_transport(&self, param: &EnteredLoginParam) -> Result<()> { + pub async fn add_or_update_transport(&self, param: &EnteredLoginParam) -> Result<()> { self.stop_io().await; let result = self.add_transport_inner(param).await; if result.is_err() { @@ -156,7 +156,7 @@ impl Context { /// Adds a new email account as a transport /// using the server encoded in the QR code. - /// See [Self::add_transport]. + /// See [Self::add_or_update_transport]. pub async fn add_transport_from_qr(&self, qr: &str) -> Result<()> { self.stop_io().await; @@ -178,7 +178,7 @@ impl Context { } /// Returns the list of all email accounts that are used as a transport in the current profile. - /// Use [Self::add_transport()] to add or change a transport + /// Use [Self::add_or_update_transport()] to add or change a transport /// and [Self::delete_transport()] to delete a transport. pub async fn list_transports(&self) -> Result> { let transports = self