mirror of
https://github.com/chatmail/core.git
synced 2026-04-02 05:22:14 +03:00
feat: Don't unarchive a group on a member removal except SELF (#5618)
This commit is contained in:
@@ -1664,7 +1664,13 @@ RETURNING id
|
||||
replace_msg_id.trash(context, on_server).await?;
|
||||
}
|
||||
|
||||
chat_id.unarchive_if_not_muted(context, state).await?;
|
||||
let unarchive = match mime_parser.get_header(HeaderDef::ChatGroupMemberRemoved) {
|
||||
Some(addr) => context.is_self_addr(addr).await?,
|
||||
None => true,
|
||||
};
|
||||
if unarchive {
|
||||
chat_id.unarchive_if_not_muted(context, state).await?;
|
||||
}
|
||||
|
||||
info!(
|
||||
context,
|
||||
|
||||
@@ -4685,6 +4685,40 @@ Chat-Group-Member-Removed: charlie@example.com",
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
async fn test_unarchive_on_member_removal() -> Result<()> {
|
||||
let mut tcm = TestContextManager::new();
|
||||
let alice = &tcm.alice().await;
|
||||
let bob = &tcm.bob().await;
|
||||
let bob_id = Contact::create(alice, "", "bob@example.net").await?;
|
||||
let fiona_id = Contact::create(alice, "", "fiona@example.net").await?;
|
||||
let alice_chat_id = create_group_chat(alice, ProtectionStatus::Unprotected, "foos").await?;
|
||||
add_contact_to_chat(alice, alice_chat_id, bob_id).await?;
|
||||
add_contact_to_chat(alice, alice_chat_id, fiona_id).await?;
|
||||
|
||||
send_text_msg(alice, alice_chat_id, "populate".to_string()).await?;
|
||||
let msg = alice.pop_sent_msg().await;
|
||||
bob.recv_msg(&msg).await;
|
||||
let bob_chat_id = bob.get_last_msg().await.chat_id;
|
||||
bob_chat_id
|
||||
.set_visibility(bob, ChatVisibility::Archived)
|
||||
.await?;
|
||||
|
||||
remove_contact_from_chat(alice, alice_chat_id, fiona_id).await?;
|
||||
let msg = alice.pop_sent_msg().await;
|
||||
bob.recv_msg(&msg).await;
|
||||
let bob_chat = Chat::load_from_db(bob, bob_chat_id).await?;
|
||||
assert_eq!(bob_chat.get_visibility(), ChatVisibility::Archived);
|
||||
|
||||
remove_contact_from_chat(alice, alice_chat_id, bob_id).await?;
|
||||
let msg = alice.pop_sent_msg().await;
|
||||
bob.recv_msg(&msg).await;
|
||||
let bob_chat = Chat::load_from_db(bob, bob_chat_id).await?;
|
||||
assert_eq!(bob_chat.get_visibility(), ChatVisibility::Normal);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
async fn test_forged_from() -> Result<()> {
|
||||
let mut tcm = TestContextManager::new();
|
||||
|
||||
Reference in New Issue
Block a user