diff --git a/src/receive_imf.rs b/src/receive_imf.rs index ef051a99e..c758a1786 100644 --- a/src/receive_imf.rs +++ b/src/receive_imf.rs @@ -807,7 +807,7 @@ async fn add_parts( // 1:1 chat is blocked, but the contact is not. // This happens when 1:1 chat is hidden // during scanning of a group invitation code. - Blocked::Request + create_blocked_default } } } diff --git a/src/receive_imf/tests.rs b/src/receive_imf/tests.rs index 9ee232a07..80fb6cf5e 100644 --- a/src/receive_imf/tests.rs +++ b/src/receive_imf/tests.rs @@ -14,6 +14,7 @@ use crate::contact; use crate::download::MIN_DOWNLOAD_LIMIT; use crate::imap::prefetch_should_download; use crate::imex::{imex, ImexMode}; +use crate::securejoin::get_securejoin_qr; use crate::test_utils::{get_chat_msg, mark_as_verified, TestContext, TestContextManager}; use crate::tools::{time, SystemTime}; @@ -3293,6 +3294,28 @@ async fn test_auto_accept_protected_group_for_bots() -> Result<()> { Ok(()) } +#[tokio::test(flavor = "multi_thread", worker_threads = 2)] +async fn test_bot_accepts_another_group_after_qr_scan() -> Result<()> { + let mut tcm = TestContextManager::new(); + let alice = &tcm.alice().await; + let bob = &tcm.bob().await; + bob.set_config(Config::Bot, Some("1")).await?; + + let group_id = chat::create_group_chat(alice, ProtectionStatus::Protected, "Group").await?; + let qr = get_securejoin_qr(alice, Some(group_id)).await?; + tcm.exec_securejoin_qr(bob, alice, &qr).await; + + let group_id = alice + .create_group_with_members(ProtectionStatus::Protected, "Group", &[bob]) + .await; + let sent = alice.send_text(group_id, "Hello!").await; + let msg = bob.recv_msg(&sent).await; + let chat = chat::Chat::load_from_db(bob, msg.chat_id).await?; + assert!(!chat.is_contact_request()); + + Ok(()) +} + #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_send_as_bot() -> Result<()> { let mut tcm = TestContextManager::new(); diff --git a/src/test_utils.rs b/src/test_utils.rs index 3d5350b74..94c23d6e7 100644 --- a/src/test_utils.rs +++ b/src/test_utils.rs @@ -175,7 +175,12 @@ impl TestContextManager { )); let qr = get_securejoin_qr(&scanned.ctx, None).await.unwrap(); - join_securejoin(&scanner.ctx, &qr).await.unwrap(); + self.exec_securejoin_qr(scanner, scanned, &qr).await; + } + + /// Executes SecureJoin initiated by `scanner` scanning `qr` generated by `scanned`. + pub async fn exec_securejoin_qr(&self, scanner: &TestContext, scanned: &TestContext, qr: &str) { + join_securejoin(&scanner.ctx, qr).await.unwrap(); loop { if let Some(sent) = scanner.pop_sent_msg_opt(Duration::ZERO).await {