Skip to content

Commit ee83649

Browse files
committed
fix: allow to scan invite links before configuration
1 parent 3267126 commit ee83649

File tree

2 files changed

+30
-17
lines changed

2 files changed

+30
-17
lines changed

src/contact.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -786,7 +786,7 @@ impl Contact {
786786

787787
let addr_normalized = addr_normalize(addr);
788788

789-
if context.is_self_addr(&addr_normalized).await? {
789+
if context.is_configured().await? && context.is_self_addr(addr).await? {
790790
return Ok(Some(ContactId::SELF));
791791
}
792792

@@ -860,12 +860,14 @@ impl Contact {
860860
);
861861
ensure!(origin != Origin::Unknown, "Missing valid origin");
862862

863-
if context.is_self_addr(addr).await? {
863+
if context.is_configured().await? && context.is_self_addr(addr).await? {
864864
return Ok((ContactId::SELF, sth_modified));
865865
}
866866

867-
if !fingerprint.is_empty() {
868-
let fingerprint_self = self_fingerprint(context).await?;
867+
if !fingerprint.is_empty() && context.is_configured().await? {
868+
let fingerprint_self = self_fingerprint(context)
869+
.await
870+
.context("self_fingerprint")?;
869871
if fingerprint == fingerprint_self {
870872
return Ok((ContactId::SELF, sth_modified));
871873
}

src/qr/qr_tests.rs

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -210,19 +210,30 @@ async fn test_decode_smtp() -> Result<()> {
210210

211211
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
212212
async fn test_decode_ideltachat_link() -> Result<()> {
213-
let ctx = TestContext::new_alice().await;
214-
215-
let qr = check_qr(
216-
&ctx.ctx,
217-
"https://i.delta.chat/#79252762C34C5096AF57958F4FC3D21A81B0F0A7&a=cli%40deltachat.de&g=test%20%3F+test%20%21&x=h-0oKQf2CDK&i=9JEXlxAqGM0&s=0V7LzL9cxRL"
218-
).await?;
219-
assert!(matches!(qr, Qr::AskVerifyGroup { .. }));
220-
221-
let qr = check_qr(
222-
&ctx.ctx,
223-
"https://i.delta.chat#79252762C34C5096AF57958F4FC3D21A81B0F0A7&a=cli%40deltachat.de&g=test%20%3F+test%20%21&x=h-0oKQf2CDK&i=9JEXlxAqGM0&s=0V7LzL9cxRL"
224-
).await?;
225-
assert!(matches!(qr, Qr::AskVerifyGroup { .. }));
213+
let mut tcm = TestContextManager::new();
214+
let ctx_configured = &tcm.alice().await;
215+
216+
// Explicitly test that scanning QR codes works
217+
// with unconfigured accounts.
218+
// This is needed for the flow where
219+
// user scans a QR code or follows invite link
220+
// and then creates a profile and e.g. joins a group
221+
// at the same time.
222+
let ctx_unconfigured = &tcm.unconfigured().await;
223+
224+
for ctx in &[ctx_configured, ctx_unconfigured] {
225+
let qr = check_qr(
226+
ctx,
227+
"https://i.delta.chat/#79252762C34C5096AF57958F4FC3D21A81B0F0A7&a=cli%40deltachat.de&g=test%20%3F+test%20%21&x=h-0oKQf2CDK&i=9JEXlxAqGM0&s=0V7LzL9cxRL"
228+
).await?;
229+
assert!(matches!(qr, Qr::AskVerifyGroup { .. }));
230+
231+
let qr = check_qr(
232+
ctx,
233+
"https://i.delta.chat#79252762C34C5096AF57958F4FC3D21A81B0F0A7&a=cli%40deltachat.de&g=test%20%3F+test%20%21&x=h-0oKQf2CDK&i=9JEXlxAqGM0&s=0V7LzL9cxRL"
234+
).await?;
235+
assert!(matches!(qr, Qr::AskVerifyGroup { .. }));
236+
}
226237

227238
Ok(())
228239
}

0 commit comments

Comments
 (0)