File tree 2 files changed +24
-0
lines changed
2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -793,6 +793,13 @@ impl ChatId {
793
793
context
794
794
. sql
795
795
. transaction ( |transaction| {
796
+ let mut stmt = transaction. prepare ( "SELECT id FROM msgs WHERE chat_id=? AND type=?" ) ?;
797
+ let rows = stmt. query_map ( ( self , Viewtype :: Webxdc ) , |row| row. get ( 0 ) ) ?;
798
+ // Let's emit events optimistically and not return webxdc `MsgId`s from the
799
+ // transaction to not add LIMIT to SELECT above.
800
+ for id in rows {
801
+ context. emit_event ( EventType :: WebxdcInstanceDeleted { msg_id : id? } ) ;
802
+ }
796
803
transaction. execute (
797
804
"UPDATE imap SET target=? WHERE rfc724_mid IN (SELECT rfc724_mid FROM msgs WHERE chat_id=?)" ,
798
805
( delete_msgs_target, self , ) ,
Original file line number Diff line number Diff line change @@ -1789,6 +1789,23 @@ async fn test_webxdc_delete_event() -> Result<()> {
1789
1789
Ok ( ( ) )
1790
1790
}
1791
1791
1792
+ #[ tokio:: test( flavor = "multi_thread" , worker_threads = 2 ) ]
1793
+ async fn test_chat_delete ( ) -> Result < ( ) > {
1794
+ let alice = & TestContext :: new_alice ( ) . await ;
1795
+ let chat_id = create_group_chat ( alice, ProtectionStatus :: Unprotected , "foo" ) . await ?;
1796
+ let instance = send_webxdc_instance ( alice, chat_id) . await ?;
1797
+ chat_id. delete ( alice) . await ?;
1798
+ let EventType :: WebxdcInstanceDeleted { msg_id } = alice
1799
+ . evtracker
1800
+ . get_matching ( |evt| matches ! ( evt, EventType :: WebxdcInstanceDeleted { .. } ) )
1801
+ . await
1802
+ else {
1803
+ unreachable ! ( ) ;
1804
+ } ;
1805
+ assert_eq ! ( msg_id, instance. id) ;
1806
+ Ok ( ( ) )
1807
+ }
1808
+
1792
1809
#[ tokio:: test( flavor = "multi_thread" , worker_threads = 2 ) ]
1793
1810
async fn change_logging_webxdc ( ) -> Result < ( ) > {
1794
1811
let alice = TestContext :: new_alice ( ) . await ;
You can’t perform that action at this time.
0 commit comments