@@ -12,6 +12,7 @@ use crate::chatlist::Chatlist;
1212use crate :: config:: Config ;
1313use crate :: ephemeral;
1414use crate :: receive_imf:: receive_imf;
15+ use crate :: securejoin:: get_securejoin_qr;
1516use crate :: test_utils:: { E2EE_INFO_MSGS , TestContext , TestContextManager } ;
1617use crate :: tools:: { self , SystemTime } ;
1718use crate :: { message, sql} ;
@@ -2195,3 +2196,42 @@ async fn test_self_addr_consistency() -> Result<()> {
21952196 assert_eq ! ( db_msg. get_webxdc_self_addr( alice) . await ?, self_addr) ;
21962197 Ok ( ( ) )
21972198}
2199+
2200+ #[ tokio:: test( flavor = "multi_thread" , worker_threads = 2 ) ]
2201+ async fn test_webxdc_info_app_sender ( ) -> Result < ( ) > {
2202+ let mut tcm = TestContextManager :: new ( ) ;
2203+ let alice = & tcm. alice ( ) . await ;
2204+ let bob = & tcm. bob ( ) . await ;
2205+
2206+ // Alice sends webxdc in a group chat
2207+ let alice_chat_id = alice. create_group_with_members ( "Group" , & [ bob] ) . await ;
2208+ let alice_instance = send_webxdc_instance ( alice, alice_chat_id) . await ?;
2209+ let sent1 = alice. pop_sent_msg ( ) . await ;
2210+ let alice_info = alice_instance. get_webxdc_info ( alice) . await ?;
2211+ assert ! ( alice_info. is_app_sender) ;
2212+ assert ! ( !alice_info. is_broadcast) ;
2213+
2214+ // Bob receives group webxdc
2215+ let bob_instance = bob. recv_msg ( & sent1) . await ;
2216+ let bob_info = bob_instance. get_webxdc_info ( bob) . await ?;
2217+ assert ! ( !bob_info. is_app_sender) ;
2218+ assert ! ( !bob_info. is_broadcast) ;
2219+
2220+ // Alice sends webxdc to broadcast channel
2221+ let alice_chat_id = create_broadcast ( alice, "Broadcast" . to_string ( ) ) . await ?;
2222+ let qr = get_securejoin_qr ( alice, Some ( alice_chat_id) ) . await . unwrap ( ) ;
2223+ tcm. exec_securejoin_qr ( bob, alice, & qr) . await ;
2224+ let alice_instance = send_webxdc_instance ( alice, alice_chat_id) . await ?;
2225+ let sent2 = alice. pop_sent_msg ( ) . await ;
2226+ let alice_info = alice_instance. get_webxdc_info ( alice) . await ?;
2227+ assert ! ( alice_info. is_app_sender) ;
2228+ assert ! ( alice_info. is_broadcast) ;
2229+
2230+ // Bob receives broadcast webxdc
2231+ let bob_instance = bob. recv_msg ( & sent2) . await ;
2232+ let bob_info = bob_instance. get_webxdc_info ( bob) . await ?;
2233+ assert ! ( !bob_info. is_app_sender) ;
2234+ assert ! ( bob_info. is_broadcast) ;
2235+
2236+ Ok ( ( ) )
2237+ }
0 commit comments