Skip to content

Commit 94e566d

Browse files
committed
Test assigning unencrypted messages with Chat-Group-ID to adhoc groups
1 parent 6deff15 commit 94e566d

File tree

2 files changed

+38
-2
lines changed

2 files changed

+38
-2
lines changed

src/receive_imf.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1473,7 +1473,7 @@ async fn do_chat_assignment(
14731473
);
14741474
}
14751475
}
1476-
ChatAssignment::AdHocGroup | ChatAssignment::OneOneChat => {
1476+
ChatAssignment::AdHocGroup => {
14771477
if let Some((new_chat_id, new_chat_id_blocked)) = lookup_or_create_adhoc_group(
14781478
context,
14791479
mime_parser,
@@ -1489,6 +1489,7 @@ async fn do_chat_assignment(
14891489
chat_id_blocked = new_chat_id_blocked;
14901490
}
14911491
}
1492+
ChatAssignment::OneOneChat => {}
14921493
}
14931494

14941495
if !to_ids.is_empty() {
@@ -3323,7 +3324,8 @@ async fn create_adhoc_group(
33233324
);
33243325
return Ok(Some((DC_CHAT_ID_TRASH, Blocked::Not)));
33253326
}
3326-
if member_ids.len() < 3 {
3327+
if member_ids.len() < 2 {
3328+
info!(context, "Not creating ad hoc group with less than 2 members.");
33273329
return Ok(None);
33283330
}
33293331

src/receive_imf/receive_imf_tests.rs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5115,3 +5115,37 @@ async fn test_no_email_contact_added_into_group() -> Result<()> {
51155115

51165116
Ok(())
51175117
}
5118+
5119+
/// Tests that message is assigned to an ad hoc group
5120+
/// if the message has a `Chat-Group-ID` even
5121+
/// if there are only two members in a group.
5122+
///
5123+
/// Since PGP-contacts introduction all groups are encrypted,
5124+
/// but old versions running on other devices might still
5125+
/// create unencrypted groups.
5126+
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
5127+
async fn test_outgoing_plaintext_two_member_group() -> Result<()> {
5128+
let mut tcm = TestContextManager::new();
5129+
let alice = &tcm.alice().await;
5130+
5131+
let msg = receive_imf(
5132+
alice,
5133+
b"From: alice@example.org\n\
5134+
To: bob@example.net\n\
5135+
Subject: foo\n\
5136+
Message-ID: <something@example.com>\n\
5137+
Chat-Version: 1.0\n\
5138+
Chat-Group-ID: 8ud29aridt29arid\n\
5139+
Date: Sun, 22 Mar 2020 22:37:57 +0000\n\
5140+
\n\
5141+
Hello\n",
5142+
false,
5143+
)
5144+
.await?
5145+
.unwrap();
5146+
5147+
let chat = Chat::load_from_db(alice, msg.chat_id).await?;
5148+
assert_eq!(chat.typ, Chattype::Group);
5149+
5150+
Ok(())
5151+
}

0 commit comments

Comments
 (0)