Skip to content

Commit 1db9b77

Browse files
authored
fix: Lowercase address in add_transport() (#6805)
1 parent a671363 commit 1db9b77

File tree

4 files changed

+37
-7
lines changed

4 files changed

+37
-7
lines changed

deltachat-jsonrpc/src/api.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,7 @@ impl CommandApi {
489489
param: EnteredLoginParam,
490490
) -> Result<()> {
491491
let ctx = self.get_context(account_id).await?;
492-
ctx.add_or_update_transport(&param.try_into()?).await
492+
ctx.add_or_update_transport(&mut param.try_into()?).await
493493
}
494494

495495
/// Deprecated 2025-04. Alias for [Self::add_or_update_transport()].

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

+6
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,12 @@ def add_or_update_transport(self, params):
115115
"""Add a new transport."""
116116
yield self._rpc.add_or_update_transport.future(self.id, params)
117117

118+
@futuremethod
119+
def list_transports(self):
120+
"""Returns the list of all email accounts that are used as a transport in the current profile."""
121+
transports = yield self._rpc.list_transports.future(self.id)
122+
return transports
123+
118124
def bring_online(self):
119125
"""Start I/O and wait until IMAP becomes IDLE."""
120126
self.start_io()

deltachat-rpc-client/tests/test_something.py

+24-1
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,29 @@ def test_configure_starttls(acfactory) -> None:
7474
assert account.is_configured()
7575

7676

77+
def test_lowercase_address(acfactory) -> None:
78+
addr, password = acfactory.get_credentials()
79+
addr_upper = addr.upper()
80+
account = acfactory.get_unconfigured_account()
81+
account.add_or_update_transport(
82+
{
83+
"addr": addr_upper,
84+
"password": password,
85+
},
86+
)
87+
assert account.is_configured()
88+
assert addr_upper != addr
89+
assert account.get_config("configured_addr") == addr
90+
assert account.list_transports()[0]["addr"] == addr
91+
92+
for param in [
93+
account.get_info()["used_account_settings"],
94+
account.get_info()["entered_account_settings"],
95+
]:
96+
assert addr in param
97+
assert addr_upper not in param
98+
99+
77100
def test_configure_ip(acfactory) -> None:
78101
addr, password = acfactory.get_credentials()
79102
account = acfactory.get_unconfigured_account()
@@ -115,7 +138,7 @@ def test_list_transports(acfactory) -> None:
115138
"imapUser": addr,
116139
},
117140
)
118-
transports = account._rpc.list_transports(account.id)
141+
transports = account.list_transports()
119142
assert len(transports) == 1
120143
params = transports[0]
121144
assert params["addr"] == addr

src/configure.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ pub(crate) mod server_params;
1616
use anyhow::{bail, ensure, format_err, Context as _, Result};
1717
use auto_mozilla::moz_autoconfigure;
1818
use auto_outlook::outlk_autodiscover;
19-
use deltachat_contact_tools::EmailAddress;
19+
use deltachat_contact_tools::{addr_normalize, EmailAddress};
2020
use futures::FutureExt;
2121
use futures_lite::FutureExt as _;
2222
use percent_encoding::utf8_percent_encode;
@@ -70,9 +70,9 @@ impl Context {
7070
/// Deprecated since 2025-02; use `add_transport_from_qr()`
7171
/// or `add_or_update_transport()` instead.
7272
pub async fn configure(&self) -> Result<()> {
73-
let param = EnteredLoginParam::load(self).await?;
73+
let mut param = EnteredLoginParam::load(self).await?;
7474

75-
self.add_transport_inner(&param).await
75+
self.add_transport_inner(&mut param).await
7676
}
7777

7878
/// Configures a new email account using the provided parameters
@@ -104,7 +104,7 @@ impl Context {
104104
/// from a server encoded in a QR code.
105105
/// - [Self::list_transports()] to get a list of all configured transports.
106106
/// - [Self::delete_transport()] to remove a transport.
107-
pub async fn add_or_update_transport(&self, param: &EnteredLoginParam) -> Result<()> {
107+
pub async fn add_or_update_transport(&self, param: &mut EnteredLoginParam) -> Result<()> {
108108
self.stop_io().await;
109109
let result = self.add_transport_inner(param).await;
110110
if result.is_err() {
@@ -117,7 +117,7 @@ impl Context {
117117
Ok(())
118118
}
119119

120-
async fn add_transport_inner(&self, param: &EnteredLoginParam) -> Result<()> {
120+
async fn add_transport_inner(&self, param: &mut EnteredLoginParam) -> Result<()> {
121121
ensure!(
122122
!self.scheduler.is_running().await,
123123
"cannot configure, already running"
@@ -126,6 +126,7 @@ impl Context {
126126
self.sql.is_open().await,
127127
"cannot configure, database not opened."
128128
);
129+
param.addr = addr_normalize(&param.addr);
129130
let old_addr = self.get_config(Config::ConfiguredAddr).await?;
130131
if self.is_configured().await? && !addr_cmp(&old_addr.unwrap_or_default(), &param.addr) {
131132
bail!("Changing your email address is not supported right now. Check back in a few months!");

0 commit comments

Comments
 (0)