Skip to content

PGP contacts #6796

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 349 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
349 commits
Select commit Hold shift + click to select a range
2eb03c4
test: add test_no_email_contacts_in_group_chats
link2xt Apr 21, 2025
78eba1d
test_no_pgp_contacts_in_adhoc_chats
link2xt Apr 21, 2025
5c0562a
Encrypted contacts must go to encrypted chats
link2xt Apr 21, 2025
9bf093a
fix chat::chat_tests::test_shall_attach_selfavatar
link2xt Apr 21, 2025
c77f523
tests::aeap::test_aeap_replay_attack
link2xt Apr 21, 2025
fce62d2
receive_imf::receive_imf_tests::test_read_receipt_and_unarchive fixed
link2xt Apr 21, 2025
ae3ae96
fix test_chat_assignment_adhoc
link2xt Apr 22, 2025
98da6ac
fix chat::chat_tests::test_chat_get_encryption_info
link2xt Apr 22, 2025
4b38776
remove test_resend_opportunistically_encryption
link2xt Apr 22, 2025
3281335
cleanup
link2xt Apr 22, 2025
9beb7f5
fix ASM
link2xt Apr 22, 2025
6474acc
fix test_unencrypted_quote_encrypted_message
link2xt Apr 22, 2025
24826ee
remove test_default_member_timestamps_to_zero
link2xt Apr 22, 2025
2ed83f0
remove receive_imf::receive_imf_tests::test_leave_protected_group_mis…
link2xt Apr 22, 2025
1ed4487
no acpeerstates in test_protected_group_add_remove_member_missing_key
link2xt Apr 22, 2025
e481198
fix securejoin::securejoin_tests::test_setup_contact_bob_knows_alice
link2xt Apr 22, 2025
438bf3c
fix securejoin::securejoin_tests::test_setup_contact_wrong_alice_gossip
link2xt Apr 22, 2025
939d265
remove receive_imf::receive_imf_tests::test_reply_from_different_addr
link2xt Apr 22, 2025
6714844
simplify test_rfc1847_encapsulation (still broken)
link2xt Apr 22, 2025
bd9f000
remove securejoin::securejoin_tests::test_shared_bobs_key
link2xt Apr 22, 2025
82493df
fix test_write_to_alice_after_aeap
link2xt Apr 22, 2025
f00f77e
fix test_message_from_old_dc_setup
link2xt Apr 23, 2025
6a239f6
remove test_old_message tests
link2xt Apr 23, 2025
10ebfe0
fixing rpc client tests
link2xt Apr 23, 2025
c2eedd0
fix verification by self
link2xt Apr 23, 2025
9d24d63
fix broadcast list synchronization
link2xt Apr 23, 2025
465e7ad
rename certificates into keys
link2xt Apr 24, 2025
a111fdc
Chat-Group-Past-Member-Fingerprints
link2xt Apr 21, 2025
bf16341
Do not encrypt to past members and do not gossip their keys
link2xt Apr 24, 2025
9a575e8
chat::chat_tests::test_past_members fixed
link2xt Apr 25, 2025
b6df044
single fingerprints header
link2xt Apr 25, 2025
cede2d2
hidden origin for past members
link2xt Apr 25, 2025
f4020c8
fixup
link2xt Apr 25, 2025
2147c1f
fixup
link2xt Apr 25, 2025
48547e5
fix chat::chat_tests::test_lost_member_added
link2xt Apr 25, 2025
92f1457
fixup
link2xt Apr 25, 2025
8fc0daa
fixup
link2xt Apr 25, 2025
62c60df
sections for test_parallel_member_remove
link2xt Apr 25, 2025
aed67e1
encrypt to removed member
link2xt Apr 25, 2025
4cdce20
recognize self in member removed messages
link2xt Apr 26, 2025
6634dd8
don't warn about missing fingerprints
link2xt Apr 26, 2025
29e7bdf
fail if no keys are available
link2xt Apr 26, 2025
0f3d605
fix tests::verified_chats::test_verified_oneonone_chat_not_broken_by_…
link2xt Apr 27, 2025
8bedaca
do not allow setting profile image for ad hoc groups and mailing lists
link2xt Apr 27, 2025
a35bf8d
replace test_group_avatar_unencrypted
link2xt Apr 27, 2025
23c90df
fix receive_imf::receive_imf_tests::test_chat_assignment_adhoc
link2xt Apr 27, 2025
d37274d
fix test_only_minimal_data_are_forwarded
link2xt Apr 27, 2025
5f0dee0
fix receive_imf::receive_imf_tests::test_no_op_member_added_is_trash
link2xt Apr 28, 2025
570b767
assign incomplete messages to whatever PGP chat
link2xt Apr 29, 2025
e4648e9
fix receive_imf::receive_imf_tests::test_create_group_with_big_msg
link2xt Apr 29, 2025
5b12fd3
clippy
link2xt Apr 30, 2025
15256c9
ignore unencrypted chat-group-id
link2xt Apr 30, 2025
dec8cf9
fix receive_imf::receive_imf_tests::test_chat_assignment_private_chat…
link2xt Apr 30, 2025
e931a05
remove test_read_receipt_and_unarchive
link2xt Apr 30, 2025
96e821f
fixed receive_imf::receive_imf_tests::test_unencrypted_group_id_no_re…
link2xt Apr 30, 2025
f308ed2
remove update_helper::tests::test_out_of_order_group_name
link2xt Apr 30, 2025
7923748
remove receive_imf::receive_imf_tests::test_prefer_chat_group_id_over…
link2xt Apr 30, 2025
b777f28
indentation
link2xt Apr 30, 2025
c06e1f2
fix receive_imf::receive_imf_tests::test_rfc1847_encapsulation
link2xt Apr 30, 2025
387f968
remove receive_imf::receive_imf_tests::test_chat_assignment_chat_grou…
link2xt Apr 30, 2025
7876f09
remove receive_imf::receive_imf_tests::test_in_reply_to_two_member_group
link2xt Apr 30, 2025
7e04f61
fix receive_imf::receive_imf_tests::test_mua_user_adds_member
link2xt Apr 30, 2025
de03339
clippy
link2xt Apr 30, 2025
a692d6d
fix test_verified_group_member_added_recovery
link2xt Apr 30, 2025
0f67efd
remove test_verified_group_recovery
link2xt Apr 30, 2025
23796c0
fix test_securejoin_after_contact_resetup
link2xt Apr 30, 2025
a997484
fix test_rename_synchronization
link2xt Apr 30, 2025
914fd42
fix tests/test_0_complex_or_slow.py::test_verified_group_vs_delete_se…
link2xt Apr 30, 2025
ba8eccd
add is_encrypted to chatlist items
link2xt Apr 30, 2025
5ba0e52
port test_name_changes from Python to Rust
link2xt Apr 30, 2025
9150631
fix test_send_and_receive_will_encrypt_decrypt
link2xt Apr 30, 2025
e932872
fix tests/test_3_offline.py::TestOfflineChat::test_audit_log_view_wit…
link2xt Apr 30, 2025
990c189
fix tests/test_3_offline.py::TestOfflineChat::test_group_chat_creation
link2xt Apr 30, 2025
81bf41f
fix test_create_chat_flexibility
link2xt Apr 30, 2025
fde8d0c
remove test_group_chat_many_members_add_remove
link2xt Apr 30, 2025
30357de
remove test_undecipherable_group
link2xt Apr 30, 2025
a09ae9c
fix test_synchronize_member_list_on_group_rejoin
link2xt Apr 30, 2025
1acedaa
fix test_removing_blocked_user_from_group
link2xt Apr 30, 2025
51e3c47
remove test_add_remove_member_remote_events
link2xt Apr 30, 2025
e4e8bcf
cleanup
link2xt Apr 30, 2025
18f7b1a
resolve todo
link2xt Apr 30, 2025
1028fa2
remove aeap_addr_changed
link2xt Apr 30, 2025
7bfe247
fixes
link2xt Apr 30, 2025
d46bda1
format python
link2xt Apr 30, 2025
ec91fc0
fix thunderbird tests and clippy
link2xt Apr 30, 2025
9a79edc
make clippy happy
link2xt Apr 30, 2025
d71d9a9
python lint
link2xt Apr 30, 2025
2e5664c
rustfmt
link2xt Apr 30, 2025
b839ba4
python formatting
link2xt Apr 30, 2025
29e0e3c
python lint
link2xt Apr 30, 2025
4f4e22f
remove group tracking not working with pgp-contacts
link2xt May 2, 2025
d50795a
fixup
link2xt May 2, 2025
3a1ddba
resolve thunderbird tests TODO
link2xt May 6, 2025
64538fa
fix test_profile_data_on_group_leave
link2xt May 6, 2025
16e3bf1
[WIP] Migration for PGP-contacts
Hocuri Apr 24, 2025
e345f97
Try to implement everything, but of course things still fail
Hocuri Apr 24, 2025
8fceae4
Add a test and make it pass
Hocuri Apr 25, 2025
7e8a003
formatting
Hocuri Apr 25, 2025
c169712
Add another test & fix problems I found
Hocuri Apr 25, 2025
e94b635
Migrate verifications, migration should be completely implemented now
Hocuri Apr 25, 2025
dae62b1
Add two more tests, without finding any bugs
Hocuri Apr 25, 2025
42e7d17
Fix some things, now my personal database is correctly migrated now
Hocuri Apr 26, 2025
544f23c
fix: Don't create PGP chat if none of the members can encrypt
Hocuri Apr 26, 2025
f160d68
feat: On error, report which SQL statement failed
Hocuri Apr 29, 2025
6e2f30e
feat: Allow to open context even though migrations failed
Hocuri Apr 29, 2025
0d47538
feat: Set migration error instead of re-using last_error
Hocuri Apr 29, 2025
72881b2
Remove outdated TODOs
Hocuri Apr 29, 2025
d76237d
fix test compilation
Hocuri Apr 29, 2025
ca3d132
Make debug=1 again for test builds
Hocuri Apr 29, 2025
4e5efc8
feat: If it's unclear who verified a contact, mark it as verified by …
Hocuri Apr 30, 2025
aefb1c8
Resolve TODO
Hocuri May 1, 2025
d93556b
Add one more info statement
Hocuri May 2, 2025
952c259
clippy, formatting
Hocuri May 5, 2025
b8de6af
Small test improvements
Hocuri May 5, 2025
640035f
fix: Prefer peerstate with newer last_seen if multiple keys have the …
Hocuri May 5, 2025
c8fb0c9
small style tweaks
Hocuri May 6, 2025
3b22df4
fix: Keep email email contact in 1:1 chat if PGP contact has a differ…
Hocuri May 6, 2025
24e798a
remove TODO
link2xt May 6, 2025
0505cba
unprotect 1:1 chats with email contacts
link2xt May 6, 2025
8fd4499
deal with NULL verifier in acpeerstates
link2xt May 6, 2025
ab94b88
mark device chat as encrypted
link2xt May 6, 2025
303c6f6
hide non-pgp contacts from contact list
link2xt May 6, 2025
443f75e
rustfmt
link2xt May 6, 2025
806f067
fix python tests
link2xt May 7, 2025
9891ca7
test fixup
link2xt May 7, 2025
b82c054
Add doc comment for get_migration_error()
Hocuri May 8, 2025
cf8a30c
typo fix
link2xt May 7, 2025
4050d8d
typo fix
link2xt May 7, 2025
078fde0
remove dots from errors
link2xt May 7, 2025
8c6d12b
failing test for chat assignment
link2xt May 7, 2025
6cb4d43
assign outgoing chat messages by references
link2xt May 8, 2025
eef17f9
comment why we dont assign the message to chat before recipient lookup
link2xt May 9, 2025
501010a
remove TODO
link2xt May 9, 2025
3e8e540
remove FIXME
link2xt May 9, 2025
463f524
missingkey
link2xt May 10, 2025
2f55190
remove securejoin timeout
link2xt May 10, 2025
1205d09
clippy
link2xt May 10, 2025
46752cd
Remove peerstate references
Hocuri May 11, 2025
56a1dba
merge main
link2xt May 12, 2025
25d9520
Update src/contact.rs
Hocuri May 15, 2025
8946ef3
Update src/imap.rs
Hocuri May 15, 2025
2b9b6aa
Update src/headerdef.rs
Hocuri May 15, 2025
088746c
Update src/contact.rs
Hocuri May 15, 2025
514c116
Update src/chat.rs
link2xt May 16, 2025
af11af9
Update src/chat.rs
link2xt May 16, 2025
c43645a
fmt
link2xt May 16, 2025
2e9531d
move parent message lookup
link2xt May 16, 2025
c9493e7
add debug assertion
link2xt May 16, 2025
f7e609d
trash undecryptable messages before chat assignment
link2xt May 17, 2025
cf0ae7b
clippy
link2xt May 17, 2025
f89e2c0
merge main into pgp-contacts
link2xt May 17, 2025
af4e3fe
test fixup after merge
link2xt May 17, 2025
2db72ae
rename get_pgp_chat into get_chat
link2xt May 17, 2025
b7a1538
replace ref with &
link2xt May 18, 2025
b0d52c2
replace parse with from_str
link2xt May 18, 2025
7f29744
remove outdated comment
link2xt May 18, 2025
1e89784
check that fingerprint is non-empty
link2xt May 18, 2025
a28670e
merge main into pgp-contacts
link2xt May 20, 2025
207d601
Update src/tests/aeap.rs
link2xt May 20, 2025
ba65f29
fix: Assign encrypted message to PGP chat if any PGP contacts found (…
iequidoo May 19, 2025
c2a2035
merge main into pgp-contacts
link2xt May 24, 2025
72614b0
test: add failing test where email contacts are added to PGP-chat
link2xt May 24, 2025
224f4d0
fix: Encrypt broadcast list in PGP-contacts migration (#6858)
Hocuri May 28, 2025
4dc0674
fix mailinglist reason, no broadcast there
link2xt May 28, 2025
ee53a54
Add ChatAssignment enum
link2xt May 16, 2025
0c35aa3
No need to check for 1 recpient once we decided on 1:1
link2xt May 17, 2025
3acfbe6
pass chat_assignment to add_parts
link2xt May 17, 2025
fd1eb7d
WIP: use chat assignment in add_parts
link2xt May 17, 2025
546e0ea
some ChatAssignment for outgoing messages
link2xt May 17, 2025
6a5df61
move parent message filtering out of add_parts
link2xt May 20, 2025
0d3e6f0
trash MDNs early
link2xt May 20, 2025
02bdff1
never allow chat creation by MDN
link2xt May 20, 2025
7afcd7d
remove outdated comment
link2xt May 20, 2025
48e840d
trash DSN early
link2xt May 20, 2025
200248f
trash more messages early
link2xt May 20, 2025
fb78402
trash webxdc status updates early
link2xt May 20, 2025
dfe9d7e
trash outgoing undecryptable messages early
link2xt May 20, 2025
1073b0b
doc comment
link2xt May 20, 2025
b8fe657
ChatAssignment::Trash
link2xt May 20, 2025
75ce32a
rustfmt
link2xt May 21, 2025
eda5f56
simplify allow_creation
link2xt May 21, 2025
15ba0a1
move trash chat assignment
link2xt May 21, 2025
91ae9d8
don't disallow trash chat creation
link2xt May 21, 2025
cc8bc70
clippy
link2xt May 21, 2025
d5b70ca
unused field
link2xt May 21, 2025
2cd6d3f
clippy
link2xt May 21, 2025
2dd96f8
is_probably_private_reply not called for messages with group ID
link2xt May 22, 2025
9cb5e09
encrypt test_send_reaction_multidevice
link2xt May 22, 2025
e9f198d
less contact IDs
link2xt May 22, 2025
c3db92b
simplify lookup_chat_by_reply
link2xt May 22, 2025
7dc1754
remove special case for alias support
link2xt May 22, 2025
aef2029
pass non-optional message into lookup_chat_by_reply
link2xt May 23, 2025
324204b
remove some dead code
link2xt May 23, 2025
44f0045
lookup_chat_by_reply refactor
link2xt May 23, 2025
62ccdb7
factoring out chat lookup by references
link2xt May 23, 2025
e679932
not too many arguments
link2xt May 23, 2025
da60ab6
ChatAssignment::ExistingChat
link2xt May 23, 2025
9a7078e
derive debug for chat assignment
link2xt May 24, 2025
99a2185
no non-members in 1:1 chats
link2xt May 24, 2025
85edc8d
trash classic emails early
link2xt May 24, 2025
792cf23
remove always-true check
link2xt May 24, 2025
98fcd09
process ChatAssignment::MailingList
link2xt May 24, 2025
e70b5ce
no wildcard match on ChatAssignment
link2xt May 24, 2025
e3f2946
unblock any chats for outgoing messages
link2xt May 24, 2025
66a3dfc
group chat assignment
link2xt May 24, 2025
279640b
refactoring
link2xt May 24, 2025
9ba0ad0
do not unassign messages from chats
link2xt May 24, 2025
205c8a2
group chat assignment
link2xt May 24, 2025
6f60473
assign chat_id_blocked
link2xt May 24, 2025
588b85b
move chat assignment closer to the beginnig for add_parts
link2xt May 24, 2025
329c36e
group group_changes
link2xt May 24, 2025
950f9a3
group chat assignment more
link2xt May 24, 2025
d49e8ba
direct check for has_chat_version
link2xt May 24, 2025
6fb0596
almost immutable chat_id
link2xt May 24, 2025
081204c
immutable chat_id
link2xt May 24, 2025
9bf73ad
immutable needs_delete_job
link2xt May 24, 2025
d5d1d39
more stuff after chat assignment
link2xt May 24, 2025
d27e850
prevent_rename after chat assignment
link2xt May 24, 2025
e717183
remove restore_protection
link2xt May 24, 2025
fba5ca3
factor out do_chat_assignment
link2xt May 24, 2025
552d86d
clippy
link2xt May 24, 2025
e6a79fb
call do_chat_assignment from receive_imf
link2xt May 24, 2025
b31b935
clippy
link2xt May 24, 2025
3d1d1e4
log chat assignment
link2xt May 24, 2025
5d456f0
lookup pgp contacts for existing PGP-chat
link2xt May 24, 2025
65bd25b
test fixup
link2xt May 24, 2025
6525a24
remove test_protected_group_reply_from_mua
link2xt May 24, 2025
e0b84b7
encrypt test_subject_in_group
link2xt May 24, 2025
b3adddc
Allow to assign partial downloads to encrypted chats
link2xt May 25, 2025
827e39c
do not lookup adhoc group for 1:1 chat
link2xt May 26, 2025
430cfe3
cleanup
link2xt May 26, 2025
881f8ff
do not ignore unencrypted Chat-Group-ID
link2xt May 26, 2025
b3ead8c
clippy
link2xt May 26, 2025
be41b24
merge main into pgp-contacts
link2xt May 29, 2025
839630f
merge pgp-contacts into chat-assignment
link2xt May 29, 2025
7ddbc19
Update src/receive_imf.rs
link2xt May 29, 2025
780afc4
Update src/receive_imf.rs
link2xt May 29, 2025
d72fcb9
Update src/receive_imf.rs
link2xt May 29, 2025
6deff15
document ExistingChat
link2xt May 30, 2025
eef4c63
Test assigning unencrypted messages with Chat-Group-ID to adhoc groups
link2xt May 30, 2025
f449f08
remove comment about OutDelivered
link2xt May 30, 2025
0455463
Update src/receive_imf.rs
link2xt May 30, 2025
10020f7
adjust GroupChat comment
link2xt May 30, 2025
4688b0b
Update src/receive_imf.rs
link2xt May 30, 2025
5bbe565
extract decide_chat_assignment
link2xt May 30, 2025
ba267d4
clippy
link2xt May 30, 2025
239174f
Update src/receive_imf.rs
link2xt May 30, 2025
fd225ca
Update src/receive_imf.rs
link2xt May 30, 2025
67add91
lint/fmt
link2xt May 30, 2025
6d764a4
Merge pull request #6868 from chatmail/link2xt/chat-assignment
link2xt May 30, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions assets/self-reporting-bot.vcf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
BEGIN:VCARD
VERSION:4.0
EMAIL:[email protected]
FN:Statistics bot
KEY:data:application/pgp-keys;base64,xjMEZbfBlBYJKwYBBAHaRw8BAQdABpLWS2PUIGGo4pslVt4R8sylP5wZihmhf1DTDr3oCMPNHDxzZWxmX3JlcG9ydGluZ0B0ZXN0cnVuLm9yZz7CiwQQFggAMwIZAQUCZbfBlAIbAwQLCQgHBhUICQoLAgMWAgEWIQTS2i16sHeYTckGn284K3M5Z4oohAAKCRA4K3M5Z4oohD8dAQCQV7CoH6UP4PD+NqI4kW5tbbqdh2AnDROg60qotmLExAEAxDfd3QHAK9f8b9qQUbLmHIztCLxhEuVbWPBEYeVW0gvOOARlt8GUEgorBgEEAZdVAQUBAQdAMBUhYoAAcI625vGZqnM5maPX4sGJ7qvJxPAFILPy6AcDAQgHwngEGBYIACAFAmW3wZQCGwwWIQTS2i16sHeYTckGn284K3M5Z4oohAAKCRA4K3M5Z4oohPwCAQCvzk1ObIkj2GqsuIfaULlgdnfdZY8LNary425CEfHZDQD5AblXVrlMO1frdlc/Vo9z3pEeCrfYdD7ITD3/OeVoiQ4=
REV:20250412T195751Z
END:VCARD
15 changes: 15 additions & 0 deletions deltachat-ffi/deltachat.h
Original file line number Diff line number Diff line change
Expand Up @@ -3838,6 +3838,21 @@ int dc_chat_can_send (const dc_chat_t* chat);
int dc_chat_is_protected (const dc_chat_t* chat);


/**
* Check if the chat is encrypted.
*
* 1:1 chats with PGP-contacts and group chats with PGP-contacts
* are encrypted.
* 1:1 chats with emails contacts and ad-hoc groups
* created for email threads are not encrypted.
*
* @memberof dc_chat_t
* @param chat The chat object.
* @return 1=chat is encrypted, 0=chat is not encrypted.
*/
int dc_chat_is_encrypted (const dc_chat_t *chat);


/**
* Checks if the chat was protected, and then an incoming message broke this protection.
*
Expand Down
13 changes: 13 additions & 0 deletions deltachat-ffi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3195,6 +3195,18 @@ pub unsafe extern "C" fn dc_chat_is_protected(chat: *mut dc_chat_t) -> libc::c_i
ffi_chat.chat.is_protected() as libc::c_int
}

#[no_mangle]
pub unsafe extern "C" fn dc_chat_is_encrypted(chat: *mut dc_chat_t) -> libc::c_int {
if chat.is_null() {
eprintln!("ignoring careless call to dc_chat_is_encrypted()");
return 0;
}
let ffi_chat = &*chat;

block_on(ffi_chat.chat.is_encrypted(&ffi_chat.context))
.unwrap_or_log_default(&ffi_chat.context, "Failed dc_chat_is_encrypted") as libc::c_int
}

#[no_mangle]
pub unsafe extern "C" fn dc_chat_is_protection_broken(chat: *mut dc_chat_t) -> libc::c_int {
if chat.is_null() {
Expand Down Expand Up @@ -4350,6 +4362,7 @@ pub unsafe extern "C" fn dc_contact_get_verifier_id(contact: *mut dc_contact_t)
.context("failed to get verifier")
.log_err(ctx)
.unwrap_or_default()
.unwrap_or_default()
.unwrap_or_default();

verifier_contact_id.to_u32()
Expand Down
23 changes: 14 additions & 9 deletions deltachat-jsonrpc/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,20 @@ impl CommandApi {
Ok(ctx.get_blobdir().to_str().map(|s| s.to_owned()))
}

/// If there was an error while the account was opened
/// and migrated to the current version,
/// then this function returns it.
///
/// This function is useful because the PGP-contacts migration could fail due to bugs
/// and then the account will not work properly.
///
/// After opening an account, the UI should call this function
/// and show the error string if one is returned.
async fn get_migration_error(&self, account_id: u32) -> Result<Option<String>> {
let ctx = self.get_context(account_id).await?;
Ok(ctx.get_migration_error())
}

/// Copy file to blob dir.
async fn copy_to_blob_dir(&self, account_id: u32, path: String) -> Result<PathBuf> {
let ctx = self.get_context(account_id).await?;
Expand Down Expand Up @@ -1542,15 +1556,6 @@ impl CommandApi {
Ok(())
}

/// Resets contact encryption.
async fn reset_contact_encryption(&self, account_id: u32, contact_id: u32) -> Result<()> {
let ctx = self.get_context(account_id).await?;
let contact_id = ContactId::new(contact_id);

contact_id.reset_encryption(&ctx).await?;
Ok(())
}

/// Sets display name for existing contact.
async fn change_contact_name(
&self,
Expand Down
5 changes: 5 additions & 0 deletions deltachat-jsonrpc/src/api/types/chat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ pub struct FullChat {
/// in the contact profile
/// if 1:1 chat with this contact exists and is protected.
is_protected: bool,
is_encrypted: bool,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
is_encrypted: bool,
/// True if the chat is encrypted.
/// This means that all messages in the chat are encrypted,
/// and all contacts in the chat are "pgp-contacts",
/// i.e. identified by the PGP key fingerprint.
///
/// False if the chat is unencrypted.
/// This means that all messages in the chat are unencrypted,
/// and all contacts in the chat are "email-contacts",
/// i.e. identified by the email address.
/// The UI should mark this chat e.g. with a mail-letter icon.
///
/// Unencrypted groups are called "ad-hoc groups"
/// and the user can't add/remove members,
/// create a QR invite code,
/// or set an avatar.
/// These options should therefore be disabled in the UI.
///
/// Note that it can happen that an encrypted chat
/// contains unencrypted messages that were received in core <= v1.159.*
/// and vice versa.
///
/// See also `is_pgp_contact` on `Contact`.
is_encrypted: bool,

profile_image: Option<String>, //BLOBS ?
archived: bool,
pinned: bool,
Expand Down Expand Up @@ -108,6 +109,7 @@ impl FullChat {
id: chat_id,
name: chat.name.clone(),
is_protected: chat.is_protected(),
is_encrypted: chat.is_encrypted(context).await?,
profile_image, //BLOBS ?
archived: chat.get_visibility() == chat::ChatVisibility::Archived,
pinned: chat.get_visibility() == chat::ChatVisibility::Pinned,
Expand Down Expand Up @@ -159,6 +161,8 @@ pub struct BasicChat {
/// in the contact profile
/// if 1:1 chat with this contact exists and is protected.
is_protected: bool,

is_encrypted: bool,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what to do about the documentation here; just duplicate it?

Suggested change
is_encrypted: bool,
/// True if the chat is encrypted.
/// This means that all messages in the chat are encrypted,
/// and all contacts in the chat are "pgp-contacts",
/// i.e. identified by the PGP key fingerprint.
///
/// False if the chat is unencrypted.
/// This means that all messages in the chat are unencrypted,
/// and all contacts in the chat are "email-contacts",
/// i.e. identified by the email address.
/// The UI should mark this chat e.g. with a mail-letter icon.
///
/// Unencrypted groups are called "ad-hoc groups"
/// and the user can't add/remove members,
/// create a QR invite code,
/// or set an avatar.
/// These options should therefore be disabled in the UI.
///
/// Note that it can happen that an encrypted chat
/// contains unencrypted messages that were received in core <= v1.159.*
/// and vice versa.
///
/// See also `is_pgp_contact` on `Contact`.
is_encrypted: bool,

profile_image: Option<String>, //BLOBS ?
archived: bool,
pinned: bool,
Expand Down Expand Up @@ -187,6 +191,7 @@ impl BasicChat {
id: chat_id,
name: chat.name.clone(),
is_protected: chat.is_protected(),
is_encrypted: chat.is_encrypted(context).await?,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This adds up to 2 additional database calls to loading BasicChat, though I can't think of a good way to avoid it, so maybe it's fine. Or maybe it should only be added to FullChat, idk.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One idea might be to have a separate chattype, SingleUnencrypted.

profile_image, //BLOBS ?
archived: chat.get_visibility() == chat::ChatVisibility::Archived,
pinned: chat.get_visibility() == chat::ChatVisibility::Pinned,
Expand Down
7 changes: 7 additions & 0 deletions deltachat-jsonrpc/src/api/types/chat_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ pub enum ChatListItemFetchResult {
/// showing preview if last chat message is image
summary_preview_image: Option<String>,
is_protected: bool,

/// True if the chat is encrypted.
///
/// False e.g. for 1:1 chats with email-contacts
/// and ad hoc groups.
is_encrypted: bool,
Comment on lines +34 to +38
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what to do about the documentation here; just duplicate it?

Suggested change
/// True if the chat is encrypted.
///
/// False e.g. for 1:1 chats with email-contacts
/// and ad hoc groups.
is_encrypted: bool,
/// True if the chat is encrypted.
/// This means that all messages in the chat are encrypted,
/// and all contacts in the chat are "pgp-contacts",
/// i.e. identified by the PGP key fingerprint.
///
/// False if the chat is unencrypted.
/// This means that all messages in the chat are unencrypted,
/// and all contacts in the chat are "email-contacts",
/// i.e. identified by the email address.
/// The UI should mark this chat e.g. with a mail-letter icon.
///
/// Unencrypted groups are called "ad-hoc groups"
/// and the user can't add/remove members,
/// create a QR invite code,
/// or set an avatar.
/// These options should therefore be disabled in the UI.
///
/// Note that it can happen that an encrypted chat
/// contains unencrypted messages that were received in core <= v1.159.*
/// and vice versa.
///
/// See also `is_pgp_contact` on `Contact`.
is_encrypted: bool,

is_group: bool,
fresh_message_counter: usize,
is_self_talk: bool,
Expand Down Expand Up @@ -137,6 +143,7 @@ pub(crate) async fn get_chat_list_item_by_id(
summary_status: summary.state.to_u32().expect("impossible"), // idea and a function to transform the constant to strings? or return string enum
summary_preview_image,
is_protected: chat.is_protected(),
is_encrypted: chat.is_encrypted(ctx).await?,
is_group: chat.get_type() == Chattype::Group,
fresh_message_counter,
is_self_talk: chat.is_self_talk(),
Expand Down
12 changes: 12 additions & 0 deletions deltachat-jsonrpc/src/api/types/contact.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,16 @@ pub struct ContactObject {
profile_image: Option<String>, // BLOBS
name_and_addr: String,
is_blocked: bool,

/// Is the contact a PGP contact.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// Is the contact a PGP contact.
/// True if the contact a "pgp-contact",
/// i.e. identified by the PGP key fingerprint.
/// Messages to pgp-contacts will always be encrypted.
///
/// False if the contact is an "email-contact",
/// i.e. identified by the email address.
/// Messages to email-contacts will always be unencrypted.
/// The UI should show e.g. a mail-letter icon next to this contact.
/// Email-contacts are usually not included in the list
/// returned by `get_contacts()` / `get_contact_ids()`.
///
/// See also `is_encrypted` on `FullChat` / `BasicChat`.

is_pgp_contact: bool,

/// Is encryption available for this contact.
///
/// This can only be true for PGP-contacts.
/// However, it is possible to have a PGP-contact
/// for which encryption is not available because we don't have a key yet,
/// e.g. if we just scanned the fingerprint from a QR code.
e2ee_avail: bool,

/// True if the contact can be added to verified groups.
Expand Down Expand Up @@ -67,6 +77,7 @@ impl ContactObject {
let verifier_id = contact
.get_verifier_id(context)
.await?
.flatten()
.map(|contact_id| contact_id.to_u32());

Ok(ContactObject {
Expand All @@ -80,6 +91,7 @@ impl ContactObject {
profile_image, //BLOBS
name_and_addr: contact.get_name_n_addr(),
is_blocked: contact.is_blocked(),
is_pgp_contact: contact.is_pgp_contact(),
e2ee_avail: contact.e2ee_avail(context).await?,
is_verified,
is_profile_verified,
Expand Down
25 changes: 5 additions & 20 deletions deltachat-repl/src/cmdline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ use deltachat::log::LogExt;
use deltachat::message::{self, Message, MessageState, MsgId, Viewtype};
use deltachat::mimeparser::SystemMessage;
use deltachat::peer_channels::{send_webxdc_realtime_advertisement, send_webxdc_realtime_data};
use deltachat::peerstate::*;
use deltachat::qr::*;
use deltachat::qr_code_generator::create_qr_svg;
use deltachat::reaction::send_reaction;
Expand All @@ -35,14 +34,6 @@ use tokio::fs;
/// e.g. bitmask 7 triggers actions defined with bits 1, 2 and 4.
async fn reset_tables(context: &Context, bits: i32) {
println!("Resetting tables ({bits})...");
if 0 != bits & 2 {
context
.sql()
.execute("DELETE FROM acpeerstates;", ())
.await
.unwrap();
println!("(2) Peerstates reset.");
}
if 0 != bits & 4 {
context
.sql()
Expand Down Expand Up @@ -277,7 +268,7 @@ async fn log_msglist(context: &Context, msglist: &[MsgId]) -> Result<()> {

async fn log_contactlist(context: &Context, contacts: &[ContactId]) -> Result<()> {
for contact_id in contacts {
let mut line2 = "".to_string();
let line2 = "".to_string();
let contact = Contact::get_by_id(context, *contact_id).await?;
let name = contact.get_display_name();
let addr = contact.get_addr();
Expand All @@ -296,15 +287,6 @@ async fn log_contactlist(context: &Context, contacts: &[ContactId]) -> Result<()
verified_str,
if !addr.is_empty() { addr } else { "addr unset" }
);
let peerstate = Peerstate::from_addr(context, addr)
.await
.expect("peerstate error");
if peerstate.is_some() && *contact_id != ContactId::SELF {
line2 = format!(
", prefer-encrypt={}",
peerstate.as_ref().unwrap().prefer_encrypt
);
}

println!("Contact#{}: {}{}", *contact_id, line, line2);
}
Expand Down Expand Up @@ -514,7 +496,10 @@ pub async fn cmdline(context: Context, line: &str, chat_id: &mut ChatId) -> Resu
ensure!(poke_spec(&context, Some(arg1)).await, "Poke failed");
}
"reset" => {
ensure!(!arg1.is_empty(), "Argument <bits> missing: 1=jobs, 2=peerstates, 4=private keys, 8=rest but server config");
ensure!(
!arg1.is_empty(),
"Argument <bits> missing: 4=private keys, 8=rest but server config"
);
let bits: i32 = arg1.parse()?;
ensure!(bits < 16, "<bits> must be lower than 16.");
reset_tables(&context, bits).await;
Expand Down
4 changes: 0 additions & 4 deletions deltachat-rpc-client/src/deltachat_rpc_client/contact.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,6 @@ def delete(self) -> None:
"""Delete contact."""
self._rpc.delete_contact(self.account.id, self.id)

def reset_encryption(self) -> None:
"""Reset contact encryption."""
self._rpc.reset_contact_encryption(self.account.id, self.id)

def set_name(self, name: str) -> None:
"""Change the name of this contact."""
self._rpc.change_contact_name(self.account.id, self.id, name)
Expand Down
Loading
Loading