Skip to content

Commit 24edee8

Browse files
committed
check if the key is available in encryption info
1 parent 1602b66 commit 24edee8

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

src/contact.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1265,7 +1265,11 @@ impl Contact {
12651265
};
12661266
let fingerprint_other = fingerprint_other.to_string();
12671267

1268-
let stock_message = stock_str::e2e_available(context).await;
1268+
let stock_message = if contact.public_key(context).await?.is_some() {
1269+
stock_str::e2e_available(context).await
1270+
} else {
1271+
stock_str::encr_none(context).await
1272+
};
12691273

12701274
let finger_prints = stock_str::finger_prints(context).await;
12711275
let mut ret = format!("{stock_message}.\n{finger_prints}:");

src/contact/contact_tests.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -771,6 +771,25 @@ CCCB 5AA9 F6E1 141C 9431
771771
);
772772
let contact = Contact::get_by_id(alice, contact_bob_id).await?;
773773
assert!(contact.e2ee_avail(alice).await?);
774+
775+
alice.sql.execute("DELETE FROM public_keys", ()).await?;
776+
let encrinfo = Contact::get_encrinfo(alice, contact_bob_id).await?;
777+
assert_eq!(
778+
encrinfo,
779+
"No encryption.
780+
Fingerprints:
781+
782+
Me (alice@example.org):
783+
2E6F A2CB 23B5 32D7 2863
784+
4B58 64B0 8F61 A9ED 9443
785+
786+
bob@example.net (bob@example.net):
787+
CCCB 5AA9 F6E1 141C 9431
788+
65F1 DB18 B18C BCF7 0487"
789+
);
790+
let contact = Contact::get_by_id(alice, contact_bob_id).await?;
791+
assert!(!contact.e2ee_avail(alice).await?);
792+
774793
Ok(())
775794
}
776795

0 commit comments

Comments
 (0)