feat: Disable sending sync messages for bots (#5705)

If currently there are no multi-device bots, let's disable sync messages for bots at all. Another
option is to auto-disable sync messages when `Config::Bot` is set, so sync messages can be reenabled
if needed. But let's leave this option for the future.
This commit is contained in:
iequidoo
2024-06-30 21:45:11 -03:00
committed by iequidoo
parent a76a2715ad
commit 5fa7cff468
2 changed files with 31 additions and 5 deletions

View File

@@ -322,7 +322,7 @@ mod tests {
use super::*;
use crate::chatlist::Chatlist;
use crate::contact::{Contact, Origin};
use crate::test_utils::TestContext;
use crate::test_utils::{TestContext, TestContextManager};
use crate::tools::SystemTime;
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
@@ -595,4 +595,30 @@ mod tests {
Ok(())
}
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn test_bot_no_sync_msgs() -> Result<()> {
let mut tcm = TestContextManager::new();
let alice = &tcm.alice().await;
let bob = &tcm.bob().await;
alice.set_config_bool(Config::SyncMsgs, true).await?;
let chat_id = alice.create_chat(bob).await.id;
chat::send_text_msg(alice, chat_id, "hi".to_string()).await?;
alice
.set_config(Config::Displayname, Some("Alice Human"))
.await?;
alice.pop_sent_msg().await; // Sync message
let msg = bob.recv_msg(&alice.pop_sent_msg().await).await;
assert_eq!(msg.text, "hi");
alice.set_config_bool(Config::Bot, true).await?;
chat::send_text_msg(alice, chat_id, "hi".to_string()).await?;
alice
.set_config(Config::Displayname, Some("Alice Bot"))
.await?;
let msg = bob.recv_msg(&alice.pop_sent_msg().await).await;
assert_eq!(msg.text, "hi");
Ok(())
}
}