fix: allow to scan invite links before configuration

This commit is contained in:
link2xt
2025-06-29 23:39:47 +00:00
committed by l
parent 3267126a33
commit ee8364913b
2 changed files with 28 additions and 15 deletions

View File

@@ -786,7 +786,7 @@ impl Contact {
let addr_normalized = addr_normalize(addr); let addr_normalized = addr_normalize(addr);
if context.is_self_addr(&addr_normalized).await? { if context.is_configured().await? && context.is_self_addr(addr).await? {
return Ok(Some(ContactId::SELF)); return Ok(Some(ContactId::SELF));
} }
@@ -860,12 +860,14 @@ impl Contact {
); );
ensure!(origin != Origin::Unknown, "Missing valid origin"); ensure!(origin != Origin::Unknown, "Missing valid origin");
if context.is_self_addr(addr).await? { if context.is_configured().await? && context.is_self_addr(addr).await? {
return Ok((ContactId::SELF, sth_modified)); return Ok((ContactId::SELF, sth_modified));
} }
if !fingerprint.is_empty() { if !fingerprint.is_empty() && context.is_configured().await? {
let fingerprint_self = self_fingerprint(context).await?; let fingerprint_self = self_fingerprint(context)
.await
.context("self_fingerprint")?;
if fingerprint == fingerprint_self { if fingerprint == fingerprint_self {
return Ok((ContactId::SELF, sth_modified)); return Ok((ContactId::SELF, sth_modified));
} }

View File

@@ -210,19 +210,30 @@ async fn test_decode_smtp() -> Result<()> {
#[tokio::test(flavor = "multi_thread", worker_threads = 2)] #[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn test_decode_ideltachat_link() -> Result<()> { async fn test_decode_ideltachat_link() -> Result<()> {
let ctx = TestContext::new_alice().await; let mut tcm = TestContextManager::new();
let ctx_configured = &tcm.alice().await;
let qr = check_qr( // Explicitly test that scanning QR codes works
&ctx.ctx, // with unconfigured accounts.
"https://i.delta.chat/#79252762C34C5096AF57958F4FC3D21A81B0F0A7&a=cli%40deltachat.de&g=test%20%3F+test%20%21&x=h-0oKQf2CDK&i=9JEXlxAqGM0&s=0V7LzL9cxRL" // This is needed for the flow where
).await?; // user scans a QR code or follows invite link
assert!(matches!(qr, Qr::AskVerifyGroup { .. })); // and then creates a profile and e.g. joins a group
// at the same time.
let ctx_unconfigured = &tcm.unconfigured().await;
let qr = check_qr( for ctx in &[ctx_configured, ctx_unconfigured] {
&ctx.ctx, let qr = check_qr(
"https://i.delta.chat#79252762C34C5096AF57958F4FC3D21A81B0F0A7&a=cli%40deltachat.de&g=test%20%3F+test%20%21&x=h-0oKQf2CDK&i=9JEXlxAqGM0&s=0V7LzL9cxRL" ctx,
).await?; "https://i.delta.chat/#79252762C34C5096AF57958F4FC3D21A81B0F0A7&a=cli%40deltachat.de&g=test%20%3F+test%20%21&x=h-0oKQf2CDK&i=9JEXlxAqGM0&s=0V7LzL9cxRL"
assert!(matches!(qr, Qr::AskVerifyGroup { .. })); ).await?;
assert!(matches!(qr, Qr::AskVerifyGroup { .. }));
let qr = check_qr(
ctx,
"https://i.delta.chat#79252762C34C5096AF57958F4FC3D21A81B0F0A7&a=cli%40deltachat.de&g=test%20%3F+test%20%21&x=h-0oKQf2CDK&i=9JEXlxAqGM0&s=0V7LzL9cxRL"
).await?;
assert!(matches!(qr, Qr::AskVerifyGroup { .. }));
}
Ok(()) Ok(())
} }