mirror of
https://github.com/chatmail/core.git
synced 2026-04-17 21:46:35 +03:00
fix: Add self-addition message to chat when recreating member list
A user reported to me that after they left a group, they were implicitly readded, but there's no any readdition message, so currently it looks in the chat like leaving it has no effect, just new messages continue to arrive. The readdition probably happened because some member didn't receive the user's self-removal message, anyway, at least there must be a message that the user is readded, even if it isn't known by whom.
This commit is contained in:
@@ -2333,6 +2333,19 @@ async fn apply_group_changes(
|
||||
context,
|
||||
"Recreating chat {chat_id} member list with {new_members:?}.",
|
||||
);
|
||||
if !self_added
|
||||
&& (chat.blocked == Blocked::Request || !chat_contacts.contains(&ContactId::SELF))
|
||||
{
|
||||
warn!(context, "Implicit addition of SELF to chat {chat_id}.");
|
||||
group_changes_msgs.push(
|
||||
stock_str::msg_add_member_local(
|
||||
context,
|
||||
&context.get_primary_self_addr().await?,
|
||||
ContactId::UNDEFINED,
|
||||
)
|
||||
.await,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if new_members != chat_contacts {
|
||||
|
||||
@@ -4447,6 +4447,20 @@ async fn test_recreate_member_list_on_missing_add_of_self() -> Result<()> {
|
||||
send_text_msg(&alice, alice_chat_id, "4th message".to_string()).await?;
|
||||
bob.recv_msg(&alice.pop_sent_msg().await).await;
|
||||
assert!(!is_contact_in_chat(&bob, bob_chat_id, ContactId::SELF).await?);
|
||||
|
||||
// But if Bob left a long time ago, they must recreate the member list after missing a message.
|
||||
SystemTime::shift(Duration::from_secs(3600));
|
||||
send_text_msg(&alice, alice_chat_id, "5th message".to_string()).await?;
|
||||
alice.pop_sent_msg().await;
|
||||
send_text_msg(&alice, alice_chat_id, "6th message".to_string()).await?;
|
||||
bob.recv_msg(&alice.pop_sent_msg().await).await;
|
||||
assert!(is_contact_in_chat(&bob, bob_chat_id, ContactId::SELF).await?);
|
||||
|
||||
bob.golden_test_chat(
|
||||
bob_chat_id,
|
||||
"receive_imf_recreate_member_list_on_missing_add_of_self",
|
||||
)
|
||||
.await;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
Group#Chat#10: Group [2 member(s)]
|
||||
--------------------------------------------------------------------------------
|
||||
Msg#10: info (Contact#Contact#Info): Member Me (bob@example.net) added. [NOTICED][INFO]
|
||||
Msg#11: (Contact#Contact#10): second message [FRESH]
|
||||
Msg#12🔒: Me (Contact#Contact#Self): You left the group. [INFO] √
|
||||
Msg#13: (Contact#Contact#10): 4th message [FRESH]
|
||||
Msg#14: info (Contact#Contact#Info): Member Me (bob@example.net) added. [NOTICED][INFO]
|
||||
Msg#15: (Contact#Contact#10): 6th message [FRESH]
|
||||
--------------------------------------------------------------------------------
|
||||
Reference in New Issue
Block a user