Skip to content

Commit 7e8e4d2

Browse files
authored
api: Rename add_transport() -> add_or_update_transport() (#6800)
cc @nicodh
1 parent 1379821 commit 7e8e4d2

File tree

6 files changed

+28
-19
lines changed

6 files changed

+28
-19
lines changed

deltachat-jsonrpc/src/api.rs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ impl CommandApi {
439439
/// Setup the credential config before calling this.
440440
///
441441
/// Deprecated as of 2025-02; use `add_transport_from_qr()`
442-
/// or `add_transport()` instead.
442+
/// or `add_or_update_transport()` instead.
443443
async fn configure(&self, account_id: u32) -> Result<()> {
444444
let ctx = self.get_context(account_id).await?;
445445
ctx.stop_io().await;
@@ -483,21 +483,30 @@ impl CommandApi {
483483
/// from a server encoded in a QR code.
484484
/// - [Self::list_transports()] to get a list of all configured transports.
485485
/// - [Self::delete_transport()] to remove a transport.
486-
async fn add_transport(&self, account_id: u32, param: EnteredLoginParam) -> Result<()> {
486+
async fn add_or_update_transport(
487+
&self,
488+
account_id: u32,
489+
param: EnteredLoginParam,
490+
) -> Result<()> {
487491
let ctx = self.get_context(account_id).await?;
488-
ctx.add_transport(&param.try_into()?).await
492+
ctx.add_or_update_transport(&param.try_into()?).await
493+
}
494+
495+
/// Deprecated 2025-04. Alias for [Self::add_or_update_transport()].
496+
async fn add_transport(&self, account_id: u32, param: EnteredLoginParam) -> Result<()> {
497+
self.add_or_update_transport(account_id, param).await
489498
}
490499

491500
/// Adds a new email account as a transport
492501
/// using the server encoded in the QR code.
493-
/// See [Self::add_transport].
502+
/// See [Self::add_or_update_transport].
494503
async fn add_transport_from_qr(&self, account_id: u32, qr: String) -> Result<()> {
495504
let ctx = self.get_context(account_id).await?;
496505
ctx.add_transport_from_qr(&qr).await
497506
}
498507

499508
/// Returns the list of all email accounts that are used as a transport in the current profile.
500-
/// Use [Self::add_transport()] to add or change a transport
509+
/// Use [Self::add_or_update_transport()] to add or change a transport
501510
/// and [Self::delete_transport()] to delete a transport.
502511
async fn list_transports(&self, account_id: u32) -> Result<Vec<EnteredLoginParam>> {
503512
let ctx = self.get_context(account_id).await?;

deltachat-rpc-client/src/deltachat_rpc_client/account.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,9 @@ def configure(self):
111111
yield self._rpc.configure.future(self.id)
112112

113113
@futuremethod
114-
def add_transport(self, params):
114+
def add_or_update_transport(self, params):
115115
"""Add a new transport."""
116-
yield self._rpc.add_transport.future(self.id, params)
116+
yield self._rpc.add_or_update_transport.future(self.id, params)
117117

118118
def bring_online(self):
119119
"""Start I/O and wait until IMAP becomes IDLE."""

deltachat-rpc-client/src/deltachat_rpc_client/pytestplugin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def new_configured_account(self):
3434
addr, password = self.get_credentials()
3535
account = self.get_unconfigured_account()
3636
params = {"addr": addr, "password": password}
37-
yield account.add_transport.future(params)
37+
yield account.add_or_update_transport.future(params)
3838

3939
assert account.is_configured()
4040
return account

deltachat-rpc-client/tests/test_account_events.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def test_event_on_configuration(acfactory: ACFactory) -> None:
1717
account = acfactory.get_unconfigured_account()
1818
account.clear_all_events()
1919
assert not account.is_configured()
20-
future = account.add_transport.future({"addr": addr, "password": password})
20+
future = account.add_or_update_transport.future({"addr": addr, "password": password})
2121
while True:
2222
event = account.wait_for_event()
2323
if event.kind == EventType.ACCOUNTS_ITEM_CHANGED:

deltachat-rpc-client/tests/test_something.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def test_acfactory(acfactory) -> None:
6363
def test_configure_starttls(acfactory) -> None:
6464
addr, password = acfactory.get_credentials()
6565
account = acfactory.get_unconfigured_account()
66-
account.add_transport(
66+
account.add_or_update_transport(
6767
{
6868
"addr": addr,
6969
"password": password,
@@ -80,7 +80,7 @@ def test_configure_ip(acfactory) -> None:
8080
ip_address = socket.gethostbyname(addr.rsplit("@")[-1])
8181

8282
with pytest.raises(JsonRpcError):
83-
account.add_transport(
83+
account.add_or_update_transport(
8484
{
8585
"addr": addr,
8686
"password": password,
@@ -94,7 +94,7 @@ def test_configure_alternative_port(acfactory) -> None:
9494
"""Test that configuration with alternative port 443 works."""
9595
addr, password = acfactory.get_credentials()
9696
account = acfactory.get_unconfigured_account()
97-
account.add_transport(
97+
account.add_or_update_transport(
9898
{
9999
"addr": addr,
100100
"password": password,
@@ -108,7 +108,7 @@ def test_configure_alternative_port(acfactory) -> None:
108108
def test_list_transports(acfactory) -> None:
109109
addr, password = acfactory.get_credentials()
110110
account = acfactory.get_unconfigured_account()
111-
account.add_transport(
111+
account.add_or_update_transport(
112112
{
113113
"addr": addr,
114114
"password": password,
@@ -420,7 +420,7 @@ def test_wait_next_messages(acfactory) -> None:
420420
addr, password = acfactory.get_credentials()
421421
bot = acfactory.get_unconfigured_account()
422422
bot.set_config("bot", "1")
423-
bot.add_transport({"addr": addr, "password": password})
423+
bot.add_or_update_transport({"addr": addr, "password": password})
424424
assert bot.is_configured()
425425

426426
# There are no old messages and the call returns immediately.
@@ -603,7 +603,7 @@ def test_reactions_for_a_reordering_move(acfactory, direct_imap):
603603

604604
addr, password = acfactory.get_credentials()
605605
ac2 = acfactory.get_unconfigured_account()
606-
ac2.add_transport({"addr": addr, "password": password})
606+
ac2.add_or_update_transport({"addr": addr, "password": password})
607607
ac2.set_config("mvbox_move", "1")
608608
assert ac2.is_configured()
609609

src/configure.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ impl Context {
6969
/// Configures this account with the currently provided parameters.
7070
///
7171
/// Deprecated since 2025-02; use `add_transport_from_qr()`
72-
/// or `add_transport()` instead.
72+
/// or `add_or_update_transport()` instead.
7373
pub async fn configure(&self) -> Result<()> {
7474
let param = EnteredLoginParam::load(self).await?;
7575

@@ -105,7 +105,7 @@ impl Context {
105105
/// from a server encoded in a QR code.
106106
/// - [Self::list_transports()] to get a list of all configured transports.
107107
/// - [Self::delete_transport()] to remove a transport.
108-
pub async fn add_transport(&self, param: &EnteredLoginParam) -> Result<()> {
108+
pub async fn add_or_update_transport(&self, param: &EnteredLoginParam) -> Result<()> {
109109
self.stop_io().await;
110110
let result = self.add_transport_inner(param).await;
111111
if result.is_err() {
@@ -156,7 +156,7 @@ impl Context {
156156

157157
/// Adds a new email account as a transport
158158
/// using the server encoded in the QR code.
159-
/// See [Self::add_transport].
159+
/// See [Self::add_or_update_transport].
160160
pub async fn add_transport_from_qr(&self, qr: &str) -> Result<()> {
161161
self.stop_io().await;
162162

@@ -178,7 +178,7 @@ impl Context {
178178
}
179179

180180
/// Returns the list of all email accounts that are used as a transport in the current profile.
181-
/// Use [Self::add_transport()] to add or change a transport
181+
/// Use [Self::add_or_update_transport()] to add or change a transport
182182
/// and [Self::delete_transport()] to delete a transport.
183183
pub async fn list_transports(&self) -> Result<Vec<EnteredLoginParam>> {
184184
let transports = self

0 commit comments

Comments
 (0)