From f311cae5ad10fc867216cf1072fdb0f8e91d0000 Mon Sep 17 00:00:00 2001 From: Hocuri Date: Tue, 15 Apr 2025 10:23:49 +0200 Subject: [PATCH] fix: Parse login scheme in `add_transport_from_qr()` (#6802) fix https://github.com/chatmail/core/issues/6801 --- src/configure.rs | 14 ++++++++++++-- src/qr.rs | 2 +- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/configure.rs b/src/configure.rs index d0bbd03d1..e0a63c7db 100644 --- a/src/configure.rs +++ b/src/configure.rs @@ -36,7 +36,6 @@ use crate::login_param::{ use crate::message::Message; use crate::oauth2::get_oauth2_addr; use crate::provider::{Protocol, Provider, Socket, UsernamePattern}; -use crate::qr::set_account_from_qr; use crate::smtp::Smtp; use crate::sync::Sync::*; use crate::tools::time; @@ -160,8 +159,19 @@ impl Context { pub async fn add_transport_from_qr(&self, qr: &str) -> Result<()> { self.stop_io().await; + // This code first sets the deprecated Config::Addr, Config::MailPw, etc. + // and then calls configure(), which loads them again. + // At some point, we will remove configure() + // and then simplify the code + // to directly create an EnteredLoginParam. let result = async move { - set_account_from_qr(self, qr).await?; + match crate::qr::check_qr(self, qr).await? { + crate::qr::Qr::Account { .. } => crate::qr::set_account_from_qr(self, qr).await?, + crate::qr::Qr::Login { address, options } => { + crate::qr::configure_from_login_qr(self, &address, options).await? + } + _ => bail!("QR code does not contain account"), + } self.configure().await?; Ok(()) } diff --git a/src/qr.rs b/src/qr.rs index 9ac6dbb5a..edfd62c12 100644 --- a/src/qr.rs +++ b/src/qr.rs @@ -10,7 +10,7 @@ use deltachat_contact_tools::{addr_normalize, may_be_valid_addr, ContactAddress} use percent_encoding::{percent_decode_str, percent_encode, NON_ALPHANUMERIC}; use serde::Deserialize; -use self::dclogin_scheme::configure_from_login_qr; +pub(crate) use self::dclogin_scheme::configure_from_login_qr; use crate::chat::ChatIdBlocked; use crate::config::Config; use crate::constants::Blocked;