mirror of
https://github.com/chatmail/core.git
synced 2026-04-17 21:46:35 +03:00
fix: Set Param::Bot for messages on the sender side as well (#5615)
This commit is contained in:
@@ -1932,6 +1932,10 @@ impl Chat {
|
||||
// reset encrypt error state eg. for forwarding
|
||||
msg.param.remove(Param::ErroneousE2ee);
|
||||
|
||||
let is_bot = context.get_config_bool(Config::Bot).await?;
|
||||
msg.param
|
||||
.set_optional(Param::Bot, Some("1").filter(|_| is_bot));
|
||||
|
||||
// Set "In-Reply-To:" to identify the message to which the composed message is a reply.
|
||||
// Set "References:" to identify the "thread" of the conversation.
|
||||
// Both according to [RFC 5322 3.6.4, page 25](https://www.rfc-editor.org/rfc/rfc5322#section-3.6.4).
|
||||
|
||||
@@ -3213,6 +3213,29 @@ async fn test_auto_accept_group_for_bots() -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
async fn test_send_as_bot() -> Result<()> {
|
||||
let mut tcm = TestContextManager::new();
|
||||
let alice = &tcm.alice().await;
|
||||
alice.set_config(Config::Bot, Some("1")).await.unwrap();
|
||||
let bob = &tcm.bob().await;
|
||||
let bob_addr = bob.get_config(Config::Addr).await?.unwrap();
|
||||
let alice_bob_id = Contact::create(alice, "", &bob_addr).await?;
|
||||
let bob_chat_id = tcm.send_recv_accept(alice, bob, "hi").await.chat_id;
|
||||
let alice_chat_id = ChatId::lookup_by_contact(alice, alice_bob_id)
|
||||
.await?
|
||||
.unwrap();
|
||||
let msg = alice.get_last_msg_in(alice_chat_id).await;
|
||||
assert!(msg.is_bot());
|
||||
let msg = bob.get_last_msg_in(bob_chat_id).await;
|
||||
assert!(msg.is_bot());
|
||||
chat::forward_msgs(bob, &[msg.id], bob_chat_id).await?;
|
||||
let msg = bob.get_last_msg_in(bob_chat_id).await;
|
||||
assert!(msg.is_forwarded());
|
||||
assert!(!msg.is_bot());
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
async fn test_no_private_reply_to_blocked_account() -> Result<()> {
|
||||
let mut tcm = TestContextManager::new();
|
||||
|
||||
Reference in New Issue
Block a user