@@ -3687,7 +3687,7 @@ async fn test_mua_can_readd() -> Result<()> {
3687
3687
}
3688
3688
3689
3689
#[ tokio:: test( flavor = "multi_thread" , worker_threads = 2 ) ]
3690
- async fn test_recreate_member_list_on_missing_add_of_self ( ) -> Result < ( ) > {
3690
+ async fn test_member_left_does_not_create_chat ( ) -> Result < ( ) > {
3691
3691
let alice = TestContext :: new_alice ( ) . await ;
3692
3692
let bob = TestContext :: new_bob ( ) . await ;
3693
3693
let alice_chat_id = create_group_chat ( & alice, ProtectionStatus :: Unprotected , "Group" ) . await ?;
@@ -3699,11 +3699,42 @@ async fn test_recreate_member_list_on_missing_add_of_self() -> Result<()> {
3699
3699
. await ?;
3700
3700
send_text_msg ( & alice, alice_chat_id, "populate" . to_string ( ) ) . await ?;
3701
3701
alice. pop_sent_msg ( ) . await ;
3702
+
3703
+ // Bob only received a message of Alice leaving the group.
3704
+ // This should not create the group.
3705
+ //
3706
+ // The reason is to avoid recreating deleted chats,
3707
+ // especially the chats that were created due to "split group" bugs
3708
+ // which some members simply deleted and some members left,
3709
+ // recreating the chat for others.
3702
3710
remove_contact_from_chat ( & alice, alice_chat_id, ContactId :: SELF ) . await ?;
3703
3711
let bob_chat_id = bob. recv_msg ( & alice. pop_sent_msg ( ) . await ) . await . chat_id ;
3712
+ assert ! ( bob_chat_id. is_trash( ) ) ;
3713
+
3714
+ Ok ( ( ) )
3715
+ }
3716
+
3717
+ #[ tokio:: test( flavor = "multi_thread" , worker_threads = 2 ) ]
3718
+ async fn test_recreate_member_list_on_missing_add_of_self ( ) -> Result < ( ) > {
3719
+ let alice = TestContext :: new_alice ( ) . await ;
3720
+ let bob = TestContext :: new_bob ( ) . await ;
3721
+ let alice_chat_id = create_group_chat ( & alice, ProtectionStatus :: Unprotected , "Group" ) . await ?;
3722
+ add_contact_to_chat (
3723
+ & alice,
3724
+ alice_chat_id,
3725
+ Contact :: create ( & alice, "bob" , & bob. get_config ( Config :: Addr ) . await ?. unwrap ( ) ) . await ?,
3726
+ )
3727
+ . await ?;
3728
+ send_text_msg ( & alice, alice_chat_id, "populate" . to_string ( ) ) . await ?;
3729
+ alice. pop_sent_msg ( ) . await ;
3730
+
3731
+ send_text_msg ( & alice, alice_chat_id, "second message" . to_string ( ) ) . await ?;
3732
+
3733
+ let bob_chat_id = bob. recv_msg ( & alice. pop_sent_msg ( ) . await ) . await . chat_id ;
3734
+ assert ! ( !bob_chat_id. is_special( ) ) ;
3704
3735
3705
3736
// Bob missed the message adding them, but must recreate the member list.
3706
- assert_eq ! ( get_chat_contacts( & bob, bob_chat_id) . await ?. len( ) , 1 ) ;
3737
+ assert_eq ! ( get_chat_contacts( & bob, bob_chat_id) . await ?. len( ) , 2 ) ;
3707
3738
assert ! ( is_contact_in_chat( & bob, bob_chat_id, ContactId :: SELF ) . await ?) ;
3708
3739
Ok ( ( ) )
3709
3740
}
0 commit comments