@@ -11,7 +11,9 @@ use crate::chat::{
1111use crate :: chatlist:: Chatlist ;
1212use crate :: config:: Config ;
1313use crate :: ephemeral;
14+ use crate :: imex:: { BackupProvider , get_backup} ;
1415use crate :: receive_imf:: receive_imf;
16+ use crate :: securejoin:: get_securejoin_qr;
1517use crate :: test_utils:: { E2EE_INFO_MSGS , TestContext , TestContextManager } ;
1618use crate :: tools:: { self , SystemTime } ;
1719use crate :: { message, sql} ;
@@ -1588,6 +1590,55 @@ async fn test_webxdc_no_internet_access() -> Result<()> {
15881590 Ok ( ( ) )
15891591}
15901592
1593+ #[ tokio:: test( flavor = "multi_thread" , worker_threads = 2 ) ]
1594+ async fn test_in_broadcast_send_status_update ( ) -> Result < ( ) > {
1595+ let mut tcm = TestContextManager :: new ( ) ;
1596+ let alice = & tcm. alice ( ) . await ;
1597+ let bob = & tcm. bob ( ) . await ;
1598+
1599+ let alice_chat_id = create_broadcast ( alice, "bc" . to_string ( ) ) . await ?;
1600+ let qr = get_securejoin_qr ( alice, Some ( alice_chat_id) ) . await ?;
1601+ let bob_chat_id = tcm. exec_securejoin_qr ( bob, alice, & qr) . await ;
1602+
1603+ let alice_instance = send_webxdc_instance ( alice, alice_chat_id) . await ?;
1604+ let sent_msg = alice. pop_sent_msg ( ) . await ;
1605+ let bob_instance = bob. recv_msg ( & sent_msg) . await ;
1606+ assert_eq ! ( bob_instance. chat_id, bob_chat_id) ;
1607+
1608+ let provider = BackupProvider :: prepare ( bob) . await ?;
1609+ let bob1 = & tcm. unconfigured ( ) . await ;
1610+ get_backup ( bob1, provider. qr ( ) ) . await ?;
1611+
1612+ bob. send_webxdc_status_update ( bob_instance. id , r#"{"payload":42}"# )
1613+ . await ?;
1614+ bob. flush_status_updates ( ) . await ?;
1615+ let sent_msg = bob. pop_sent_msg ( ) . await ;
1616+
1617+ alice. recv_msg_trash ( & sent_msg) . await ;
1618+ assert_eq ! (
1619+ alice
1620+ . get_webxdc_status_updates( alice_instance. id, StatusUpdateSerial ( 0 ) )
1621+ . await ?,
1622+ r#"[{"payload":42,"serial":1,"max_serial":1}]"#
1623+ ) ;
1624+
1625+ bob1. recv_msg_trash ( & sent_msg) . await ;
1626+ assert_eq ! (
1627+ bob1. get_webxdc_status_updates( bob_instance. id, StatusUpdateSerial ( 0 ) )
1628+ . await ?,
1629+ r#"[{"payload":42,"serial":1,"max_serial":1}]"#
1630+ ) ;
1631+
1632+ // Non-subscriber's status updates are rejected.
1633+ let alice_bob_id = alice. add_or_lookup_contact_id ( bob) . await ;
1634+ remove_contact_from_chat ( alice, alice_chat_id, alice_bob_id) . await ?;
1635+ alice. pop_sent_msg ( ) . await ;
1636+ let status =
1637+ helper_send_receive_status_update ( bob, alice, & bob_instance, & alice_instance) . await ?;
1638+ assert_eq ! ( status, r#"[{"payload":42,"serial":1,"max_serial":1}]"# ) ;
1639+ Ok ( ( ) )
1640+ }
1641+
15911642#[ tokio:: test( flavor = "multi_thread" , worker_threads = 2 ) ]
15921643async fn test_webxdc_chatlist_summary ( ) -> Result < ( ) > {
15931644 let t = TestContext :: new_alice ( ) . await ;
0 commit comments