From ba36d09c700bd967c246b1a5720b2a1d0d31e9b4 Mon Sep 17 00:00:00 2001 From: link2xt Date: Fri, 5 May 2023 12:49:23 +0000 Subject: [PATCH] Make the bots automatically accept group chat contact requests --- CHANGELOG.md | 2 ++ src/receive_imf.rs | 8 +++++++- src/receive_imf/tests.rs | 11 +++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 359ab0d20..d7464eacc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ - BREAKING: jsonrpc: - `get_chatlist_items_by_entries` now takes only chatids instead of `ChatListEntries` - `get_chatlist_entries` now returns `Vec` of chatids instead of `ChatListEntries` +### Fixes +- Make the bots automatically accept group chat contact requests. #4377 ## [1.114.0] - 2023-04-24 diff --git a/src/receive_imf.rs b/src/receive_imf.rs index b321c2f67..812327b18 100644 --- a/src/receive_imf.rs +++ b/src/receive_imf.rs @@ -557,7 +557,13 @@ async fn add_parts( blocked: Blocked::Request, }) if is_bot => Blocked::Not, Some(ChatIdBlocked { id: _, blocked }) => blocked, - None => Blocked::Request, + None => { + if is_bot { + Blocked::Not + } else { + Blocked::Request + } + } }; if chat_id.is_none() { diff --git a/src/receive_imf/tests.rs b/src/receive_imf/tests.rs index 44d3b8d9d..1fda38221 100644 --- a/src/receive_imf/tests.rs +++ b/src/receive_imf/tests.rs @@ -2980,6 +2980,17 @@ async fn test_auto_accept_for_bots() -> Result<()> { Ok(()) } +#[tokio::test(flavor = "multi_thread", worker_threads = 2)] +async fn test_auto_accept_group_for_bots() -> Result<()> { + let t = TestContext::new_alice().await; + t.set_config(Config::Bot, Some("1")).await.unwrap(); + receive_imf(&t, GRP_MAIL, false).await?; + let msg = t.get_last_msg().await; + let chat = chat::Chat::load_from_db(&t, msg.chat_id).await?; + assert!(!chat.is_contact_request()); + Ok(()) +} + #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_no_private_reply_to_blocked_account() -> Result<()> { let mut tcm = TestContextManager::new();