@@ -7808,4 +7808,36 @@ mod tests {
7808
7808
7809
7809
Ok ( ( ) )
7810
7810
}
7811
+
7812
+ /// Test that tombstones for past members are added to chats_contacts table
7813
+ /// even if the row did not exist before.
7814
+ #[ tokio:: test( flavor = "multi_thread" , worker_threads = 2 ) ]
7815
+ async fn test_past_members ( ) -> Result < ( ) > {
7816
+ let mut tcm = TestContextManager :: new ( ) ;
7817
+
7818
+ let alice = & tcm. alice ( ) . await ;
7819
+ let alice_fiona_contact_id = Contact :: create ( alice, "Fiona" , "fiona@example.net" ) . await ?;
7820
+
7821
+ let alice_chat_id =
7822
+ create_group_chat ( alice, ProtectionStatus :: Unprotected , "Group chat" ) . await ?;
7823
+ add_contact_to_chat ( alice, alice_chat_id, alice_fiona_contact_id) . await ?;
7824
+ alice
7825
+ . send_text ( alice_chat_id, "Hi! I created a group." )
7826
+ . await ;
7827
+ remove_contact_from_chat ( alice, alice_chat_id, alice_fiona_contact_id) . await ?;
7828
+ assert_eq ! ( get_past_chat_contacts( alice, alice_chat_id) . await ?. len( ) , 1 ) ;
7829
+
7830
+ let bob = & tcm. bob ( ) . await ;
7831
+ let bob_addr = bob. get_config ( Config :: Addr ) . await ?. unwrap ( ) ;
7832
+ let alice_bob_contact_id = Contact :: create ( alice, "Bob" , & bob_addr) . await ?;
7833
+ add_contact_to_chat ( alice, alice_chat_id, alice_bob_contact_id) . await ?;
7834
+
7835
+ let add_message = alice. pop_sent_msg ( ) . await ;
7836
+ let bob_add_message = bob. recv_msg ( & add_message) . await ;
7837
+ let bob_chat_id = bob_add_message. chat_id ;
7838
+ assert_eq ! ( get_chat_contacts( bob, bob_chat_id) . await ?. len( ) , 2 ) ;
7839
+ assert_eq ! ( get_past_chat_contacts( bob, bob_chat_id) . await ?. len( ) , 1 ) ;
7840
+
7841
+ Ok ( ( ) )
7842
+ }
7811
7843
}
0 commit comments