mirror of
https://github.com/chatmail/core.git
synced 2026-05-09 01:46:30 +03:00
refactor: Rename EnteredLoginParam::load() and save() to load_legacy() and save_legacy()
This commit is contained in:
@@ -138,10 +138,11 @@ pub struct EnteredLoginParam {
|
||||
}
|
||||
|
||||
impl EnteredLoginParam {
|
||||
/// Loads entered account settings.
|
||||
/// Loads entered account settings
|
||||
/// that were set by the deprecated `configured_*` configs.
|
||||
///
|
||||
/// This is a legacy API for loading from separate config parameters.
|
||||
pub(crate) async fn load(context: &Context) -> Result<Self> {
|
||||
/// This is only needed by tests and clients using the old CFFI API.
|
||||
pub(crate) async fn load_legacy(context: &Context) -> Result<Self> {
|
||||
let addr = context
|
||||
.get_config(Config::Addr)
|
||||
.await?
|
||||
@@ -241,7 +242,10 @@ impl EnteredLoginParam {
|
||||
|
||||
/// Saves entered account settings,
|
||||
/// so that they can be prefilled if the user wants to configure the server again.
|
||||
pub(crate) async fn save(&self, context: &Context) -> Result<()> {
|
||||
///
|
||||
/// This is needed in case a UI is not yet updated, and still uses `get_config("mail_pw")` etc.
|
||||
/// in order to prefill the entered account settings.
|
||||
pub(crate) async fn save_legacy(&self, context: &Context) -> Result<()> {
|
||||
context.set_config(Config::Addr, Some(&self.addr)).await?;
|
||||
|
||||
context
|
||||
@@ -364,7 +368,7 @@ mod tests {
|
||||
.await?;
|
||||
t.set_config(Config::MailPw, Some("foobarbaz")).await?;
|
||||
|
||||
let param = EnteredLoginParam::load(t).await?;
|
||||
let param = EnteredLoginParam::load_legacy(t).await?;
|
||||
assert_eq!(param.addr, "alice@example.org");
|
||||
assert_eq!(
|
||||
param.certificate_checks,
|
||||
@@ -373,13 +377,13 @@ mod tests {
|
||||
|
||||
t.set_config(Config::ImapCertificateChecks, Some("1"))
|
||||
.await?;
|
||||
let param = EnteredLoginParam::load(t).await?;
|
||||
let param = EnteredLoginParam::load_legacy(t).await?;
|
||||
assert_eq!(param.certificate_checks, EnteredCertificateChecks::Strict);
|
||||
|
||||
// Fail to load invalid settings, but do not panic.
|
||||
t.set_config(Config::ImapCertificateChecks, Some("999"))
|
||||
.await?;
|
||||
assert!(EnteredLoginParam::load(t).await.is_err());
|
||||
assert!(EnteredLoginParam::load_legacy(t).await.is_err());
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -407,7 +411,7 @@ mod tests {
|
||||
certificate_checks: Default::default(),
|
||||
oauth2: false,
|
||||
};
|
||||
param.save(&t).await?;
|
||||
param.save_legacy(&t).await?;
|
||||
assert_eq!(
|
||||
t.get_config(Config::Addr).await?.unwrap(),
|
||||
"alice@example.org"
|
||||
@@ -416,7 +420,7 @@ mod tests {
|
||||
assert_eq!(t.get_config(Config::SendPw).await?, None);
|
||||
assert_eq!(t.get_config_int(Config::SendPort).await?, 2947);
|
||||
|
||||
assert_eq!(EnteredLoginParam::load(&t).await?, param);
|
||||
assert_eq!(EnteredLoginParam::load_legacy(&t).await?, param);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user