Skip to content

Commit 374a5ef

Browse files
committed
feat: Don't apply chat name and avatar changes from non-members
Non-members can't modify the member list (incl. adding themselves), modify an ephemeral timer, so they shouldn't be able to change the group name or avatar, just for consistency. Even if messages are reordered and a group name change from a new member arrives before its addition, the new group name will be applied on a receipt of the next message following the addition message because Chat-Group-Name-Timestamp increases. While Delta Chat groups aimed for chatting with trusted contacts, accepting group changes from everyone knowing Chat-Group-Id means that if any of the past members have the key compromised, the group should be recreated which looks impractical.
1 parent 1a2e355 commit 374a5ef

File tree

2 files changed

+16
-12
lines changed

2 files changed

+16
-12
lines changed

src/receive_imf.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2899,17 +2899,17 @@ async fn apply_group_changes(
28992899
}
29002900
}
29012901

2902-
apply_chat_name_and_avatar_changes(
2903-
context,
2904-
mime_parser,
2905-
from_id,
2906-
chat,
2907-
&mut send_event_chat_modified,
2908-
&mut better_msg,
2909-
)
2910-
.await?;
2911-
29122902
if is_from_in_chat {
2903+
apply_chat_name_and_avatar_changes(
2904+
context,
2905+
mime_parser,
2906+
from_id,
2907+
chat,
2908+
&mut send_event_chat_modified,
2909+
&mut better_msg,
2910+
)
2911+
.await?;
2912+
29132913
if chat.member_list_is_stale(context).await? {
29142914
info!(context, "Member list is stale.");
29152915
let mut new_members: HashSet<ContactId> =

src/receive_imf/receive_imf_tests.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4212,14 +4212,18 @@ async fn test_keep_member_list_if_possibly_nomember() -> Result<()> {
42124212
let fiona_chat_id = fiona.recv_msg(&alice.pop_sent_msg().await).await.chat_id;
42134213
fiona_chat_id.accept(&fiona).await?;
42144214

4215-
send_text_msg(&fiona, fiona_chat_id, "hi".to_string()).await?;
4215+
SystemTime::shift(Duration::from_secs(60));
4216+
chat::set_chat_name(&fiona, fiona_chat_id, "Renamed").await?;
42164217
bob.recv_msg(&fiona.pop_sent_msg().await).await;
42174218

4218-
// Bob missed the message adding fiona, but mustn't recreate the member list.
4219+
// Bob missed the message adding fiona, but mustn't recreate the member list or apply the group
4220+
// name change.
42194221
assert_eq!(get_chat_contacts(&bob, bob_chat_id).await?.len(), 2);
42204222
assert!(is_contact_in_chat(&bob, bob_chat_id, ContactId::SELF).await?);
42214223
let bob_alice_contact = bob.add_or_lookup_contact_id(&alice).await;
42224224
assert!(is_contact_in_chat(&bob, bob_chat_id, bob_alice_contact).await?);
4225+
let chat = Chat::load_from_db(&bob, bob_chat_id).await?;
4226+
assert_eq!(chat.get_name(), "Group");
42234227
Ok(())
42244228
}
42254229

0 commit comments

Comments
 (0)