Skip to content

Commit 5a6b1c6

Browse files
committed
refactor: Rename EnteredLoginParam::load() and save() to load_legacy() and save_legacy()
1 parent 18d8783 commit 5a6b1c6

3 files changed

Lines changed: 16 additions & 12 deletions

File tree

src/configure.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ impl Context {
7676
/// Deprecated since 2025-02; use `add_transport_from_qr()`
7777
/// or `add_or_update_transport()` instead.
7878
pub async fn configure(&self) -> Result<()> {
79-
let mut param = EnteredLoginParam::load(self).await?;
79+
let mut param = EnteredLoginParam::load_legacy(self).await?;
8080

8181
self.add_transport_inner(&mut param).await
8282
}
@@ -150,7 +150,7 @@ impl Context {
150150
progress!(self, 0, Some(error_msg.clone()));
151151
bail!(error_msg);
152152
} else {
153-
param.save(self).await?;
153+
param.save_legacy(self).await?;
154154
progress!(self, 1000);
155155
}
156156

src/login_param.rs

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,11 @@ pub struct EnteredLoginParam {
138138
}
139139

140140
impl EnteredLoginParam {
141-
/// Loads entered account settings.
141+
/// Loads entered account settings
142+
/// that were set by the deprecated `configured_*` configs.
142143
///
143-
/// This is a legacy API for loading from separate config parameters.
144-
pub(crate) async fn load(context: &Context) -> Result<Self> {
144+
/// This is only needed by tests and clients using the old CFFI API.
145+
pub(crate) async fn load_legacy(context: &Context) -> Result<Self> {
145146
let addr = context
146147
.get_config(Config::Addr)
147148
.await?
@@ -241,7 +242,10 @@ impl EnteredLoginParam {
241242

242243
/// Saves entered account settings,
243244
/// so that they can be prefilled if the user wants to configure the server again.
244-
pub(crate) async fn save(&self, context: &Context) -> Result<()> {
245+
///
246+
/// This is needed in case a UI is not yet updated, and still uses `get_config("mail_pw")` etc.
247+
/// in order to prefill the entered account settings.
248+
pub(crate) async fn save_legacy(&self, context: &Context) -> Result<()> {
245249
context.set_config(Config::Addr, Some(&self.addr)).await?;
246250

247251
context
@@ -364,7 +368,7 @@ mod tests {
364368
.await?;
365369
t.set_config(Config::MailPw, Some("foobarbaz")).await?;
366370

367-
let param = EnteredLoginParam::load(t).await?;
371+
let param = EnteredLoginParam::load_legacy(t).await?;
368372
assert_eq!(param.addr, "alice@example.org");
369373
assert_eq!(
370374
param.certificate_checks,
@@ -373,13 +377,13 @@ mod tests {
373377

374378
t.set_config(Config::ImapCertificateChecks, Some("1"))
375379
.await?;
376-
let param = EnteredLoginParam::load(t).await?;
380+
let param = EnteredLoginParam::load_legacy(t).await?;
377381
assert_eq!(param.certificate_checks, EnteredCertificateChecks::Strict);
378382

379383
// Fail to load invalid settings, but do not panic.
380384
t.set_config(Config::ImapCertificateChecks, Some("999"))
381385
.await?;
382-
assert!(EnteredLoginParam::load(t).await.is_err());
386+
assert!(EnteredLoginParam::load_legacy(t).await.is_err());
383387

384388
Ok(())
385389
}
@@ -407,7 +411,7 @@ mod tests {
407411
certificate_checks: Default::default(),
408412
oauth2: false,
409413
};
410-
param.save(&t).await?;
414+
param.save_legacy(&t).await?;
411415
assert_eq!(
412416
t.get_config(Config::Addr).await?.unwrap(),
413417
"alice@example.org"
@@ -416,7 +420,7 @@ mod tests {
416420
assert_eq!(t.get_config(Config::SendPw).await?, None);
417421
assert_eq!(t.get_config_int(Config::SendPort).await?, 2947);
418422

419-
assert_eq!(EnteredLoginParam::load(&t).await?, param);
423+
assert_eq!(EnteredLoginParam::load_legacy(&t).await?, param);
420424

421425
Ok(())
422426
}

src/sql/migrations.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1919,7 +1919,7 @@ CREATE INDEX gossip_timestamp_index ON gossip_timestamp (chat_id, fingerprint);
19191919

19201920
inc_and_check(&mut migration_version, 131)?;
19211921
if dbversion < migration_version {
1922-
let entered_param = EnteredLoginParam::load(context).await?;
1922+
let entered_param = EnteredLoginParam::load_legacy(context).await?;
19231923
let configured_param = ConfiguredLoginParam::load_legacy(context).await?;
19241924

19251925
sql.execute_migration_transaction(

0 commit comments

Comments
 (0)