feat: key-contacts

This change introduces a new type of contacts
identified by their public key fingerprint
rather than an e-mail address.

Encrypted chats now stay encrypted
and unencrypted chats stay unencrypted.
For example, 1:1 chats with key-contacts
are encrypted and 1:1 chats with address-contacts
are unencrypted.
Groups that have a group ID are encrypted
and can only contain key-contacts
while groups that don't have a group ID ("adhoc groups")
are unencrypted and can only contain address-contacts.

JSON-RPC API `reset_contact_encryption` is removed.
Python API `Contact.reset_encryption` is removed.
"Group tracking plugin" in legacy Python API was removed because it
relied on parsing email addresses from system messages with regexps.

Co-authored-by: Hocuri <hocuri@gmx.de>
Co-authored-by: iequidoo <dgreshilov@gmail.com>
Co-authored-by: B. Petersen <r10s@b44t.com>
This commit is contained in:
link2xt
2025-06-26 14:07:39 +00:00
parent 7ac04d0204
commit 416131b4a2
84 changed files with 4735 additions and 6338 deletions

View File

@@ -70,20 +70,7 @@ async fn test_stock_system_msg_simple() {
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn test_stock_system_msg_add_member_by_me() {
let t = TestContext::new().await;
assert_eq!(
msg_add_member_remote(&t, "alice@example.org").await,
"I added member alice@example.org."
);
assert_eq!(
msg_add_member_local(&t, "alice@example.org", ContactId::SELF).await,
"You added member alice@example.org."
)
}
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn test_stock_system_msg_add_member_by_me_with_displayname() {
let t = TestContext::new().await;
Contact::create(&t, "Alice", "alice@example.org")
let alice_contact_id = Contact::create(&t, "Alice", "alice@example.org")
.await
.expect("failed to create contact");
assert_eq!(
@@ -91,7 +78,23 @@ async fn test_stock_system_msg_add_member_by_me_with_displayname() {
"I added member alice@example.org."
);
assert_eq!(
msg_add_member_local(&t, "alice@example.org", ContactId::SELF).await,
msg_add_member_local(&t, alice_contact_id, ContactId::SELF).await,
"You added member Alice."
)
}
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn test_stock_system_msg_add_member_by_me_with_displayname() {
let t = TestContext::new().await;
let alice_contact_id = Contact::create(&t, "Alice", "alice@example.org")
.await
.expect("failed to create contact");
assert_eq!(
msg_add_member_remote(&t, "alice@example.org").await,
"I added member alice@example.org."
);
assert_eq!(
msg_add_member_local(&t, alice_contact_id, ContactId::SELF).await,
"You added member Alice."
);
}
@@ -99,16 +102,14 @@ async fn test_stock_system_msg_add_member_by_me_with_displayname() {
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn test_stock_system_msg_add_member_by_other_with_displayname() {
let t = TestContext::new().await;
let contact_id = {
Contact::create(&t, "Alice", "alice@example.org")
.await
.expect("Failed to create contact Alice");
Contact::create(&t, "Bob", "bob@example.com")
.await
.expect("failed to create bob")
};
let alice_contact_id = Contact::create(&t, "Alice", "alice@example.org")
.await
.expect("Failed to create contact Alice");
let bob_contact_id = Contact::create(&t, "Bob", "bob@example.com")
.await
.expect("failed to create bob");
assert_eq!(
msg_add_member_local(&t, "alice@example.org", contact_id,).await,
msg_add_member_local(&t, alice_contact_id, bob_contact_id).await,
"Member Alice added by Bob."
);
}
@@ -133,7 +134,7 @@ async fn test_partial_download_msg_body() -> Result<()> {
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn test_update_device_chats() {
let t = TestContext::new().await;
let t = TestContext::new_alice().await;
t.update_device_chats().await.ok();
let chats = Chatlist::try_load(&t, 0, None, None).await.unwrap();
assert_eq!(chats.len(), 2);