add delete event for webxdc

This commit is contained in:
Sebastian Klähn
2022-09-10 19:27:20 +02:00
parent 7cff681234
commit 24d9345ea0
4 changed files with 27 additions and 0 deletions

View File

@@ -302,4 +302,9 @@ pub enum EventType {
msg_id: MsgId,
status_update_serial: StatusUpdateSerial,
},
/// Inform that an instance cointaining a webxdc has been deleted
WebXdInstanceDeleted {
msg_id: MsgId,
},
}

View File

@@ -1236,6 +1236,9 @@ pub async fn delete_msgs(context: &Context, msg_ids: &[MsgId]) -> Result<()> {
.trash(context)
.await
.with_context(|| format!("Unable to trash message {}", msg_id))?;
context.emit_event(EventType::WebXdInstanceDeleted { msg_id: *msg_id });
context
.sql
.execute(

View File

@@ -753,6 +753,7 @@ mod tests {
use crate::chatlist::Chatlist;
use crate::config::Config;
use crate::contact::Contact;
use crate::message;
use crate::receive_imf::{receive_imf, receive_imf_inner};
use crate::test_utils::TestContext;
@@ -2377,4 +2378,18 @@ sth_for_the = "future""#
);
Ok(())
}
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn test_webxdc_delete_event() -> Result<()> {
let alice = TestContext::new_alice().await;
let chat_id = create_group_chat(&alice, ProtectionStatus::Unprotected, "foo").await?;
let instance = send_webxdc_instance(&alice, chat_id).await?;
//let msg_id = alice.pop_sent_msg().await;
message::delete_msgs(&alice, &[instance.id]).await?;
alice
.evtracker
.get_matching(|evt| matches!(evt, EventType::WebXdInstanceDeleted { .. }))
.await;
Ok(())
}
}