diff --git a/src/receive_imf.rs b/src/receive_imf.rs index 9a59a4624..82c089908 100644 --- a/src/receive_imf.rs +++ b/src/receive_imf.rs @@ -1271,11 +1271,15 @@ async fn decide_chat_assignment( chat_id, chat_id_blocked, } + } else if mime_parser.get_header(HeaderDef::ChatGroupName).is_some() { + ChatAssignment::AdHocGroup } else if num_recipients <= 1 { ChatAssignment::OneOneChat } else { ChatAssignment::AdHocGroup } + } else if mime_parser.get_header(HeaderDef::ChatGroupName).is_some() { + ChatAssignment::AdHocGroup } else if num_recipients <= 1 { ChatAssignment::OneOneChat } else { diff --git a/src/receive_imf/receive_imf_tests.rs b/src/receive_imf/receive_imf_tests.rs index a8ba00785..1a65ca808 100644 --- a/src/receive_imf/receive_imf_tests.rs +++ b/src/receive_imf/receive_imf_tests.rs @@ -5406,3 +5406,33 @@ async fn test_encrypted_adhoc_group_message() -> Result<()> { Ok(()) } + +/// Tests that messages sent to unencrypted group +/// with only two members arrive in a group +/// and not in 1:1 chat. +#[tokio::test(flavor = "multi_thread", worker_threads = 2)] +async fn test_small_unencrypted_group() -> Result<()> { + let mut tcm = TestContextManager::new(); + let alice = &tcm.alice().await; + let bob = &tcm.bob().await; + + let alice_chat_id = chat::create_group_ex(alice, None, "Unencrypted group").await?; + let alice_bob_id = alice.add_or_lookup_address_contact_id(bob).await; + add_contact_to_chat(alice, alice_chat_id, alice_bob_id).await?; + send_text_msg(alice, alice_chat_id, "Hello!".to_string()).await?; + + let sent_msg = alice.pop_sent_msg().await; + let bob_chat_id = bob.recv_msg(&sent_msg).await.chat_id; + let bob_chat = Chat::load_from_db(bob, bob_chat_id).await?; + + assert_eq!(bob_chat.typ, Chattype::Group); + assert_eq!(bob_chat.is_encrypted(bob).await?, false); + + bob_chat_id.accept(bob).await?; + send_text_msg(bob, bob_chat_id, "Hello back!".to_string()).await?; + let sent_msg = bob.pop_sent_msg().await; + let alice_rcvd_msg = alice.recv_msg(&sent_msg).await; + assert_eq!(alice_rcvd_msg.chat_id, alice_chat_id); + + Ok(()) +}