diff --git a/crates/matrix-sdk-base/src/store/integration_tests.rs b/crates/matrix-sdk-base/src/store/integration_tests.rs index 3fb6ac0bc9d..26412fa8aca 100644 --- a/crates/matrix-sdk-base/src/store/integration_tests.rs +++ b/crates/matrix-sdk-base/src/store/integration_tests.rs @@ -972,6 +972,24 @@ impl StateStoreIntegrationTests for DynStateStore { self.populate().await?; + { + // Add a send queue request in that room. + let txn = TransactionId::new(); + let ev = + SerializableEventContent::new(&RoomMessageEventContent::text_plain("sup").into()) + .unwrap(); + self.save_send_queue_request(room_id, txn.clone(), ev.into(), 0).await?; + + // Add a single dependent queue request. + self.save_dependent_queued_request( + room_id, + &txn, + ChildTransactionId::new(), + DependentQueuedRequestKind::RedactEvent, + ) + .await?; + } + self.remove_room(room_id).await?; assert_eq!(self.get_room_infos().await?.len(), 1, "room is still there"); @@ -1023,6 +1041,8 @@ impl StateStoreIntegrationTests for DynStateStore { .is_empty(), "still event recepts in the store" ); + assert!(self.load_send_queue_requests(room_id).await?.is_empty()); + assert!(self.load_dependent_queued_requests(room_id).await?.is_empty()); self.remove_room(stripped_room_id).await?; diff --git a/crates/matrix-sdk-base/src/store/memory_store.rs b/crates/matrix-sdk-base/src/store/memory_store.rs index ac2951be983..623fba571b9 100644 --- a/crates/matrix-sdk-base/src/store/memory_store.rs +++ b/crates/matrix-sdk-base/src/store/memory_store.rs @@ -796,6 +796,8 @@ impl StateStore for MemoryStore { self.stripped_members.write().unwrap().remove(room_id); self.room_user_receipts.write().unwrap().remove(room_id); self.room_event_receipts.write().unwrap().remove(room_id); + self.send_queue_events.write().unwrap().remove(room_id); + self.dependent_send_queue_events.write().unwrap().remove(room_id); Ok(()) } diff --git a/crates/matrix-sdk-sqlite/src/state_store.rs b/crates/matrix-sdk-sqlite/src/state_store.rs index 02aeb0f545a..b67b7c459c0 100644 --- a/crates/matrix-sdk-sqlite/src/state_store.rs +++ b/crates/matrix-sdk-sqlite/src/state_store.rs @@ -509,6 +509,7 @@ trait SqliteConnectionStateStoreExt { fn remove_display_name(&self, room_id: &[u8], name: &[u8]) -> rusqlite::Result<()>; fn remove_room_display_names(&self, room_id: &[u8]) -> rusqlite::Result<()>; fn remove_room_send_queue(&self, room_id: &[u8]) -> rusqlite::Result<()>; + fn remove_room_dependent_send_queue(&self, room_id: &[u8]) -> rusqlite::Result<()>; } impl SqliteConnectionStateStoreExt for rusqlite::Connection { @@ -720,6 +721,12 @@ impl SqliteConnectionStateStoreExt for rusqlite::Connection { self.prepare("DELETE FROM send_queue_events WHERE room_id = ?")?.execute((room_id,))?; Ok(()) } + + fn remove_room_dependent_send_queue(&self, room_id: &[u8]) -> rusqlite::Result<()> { + self.prepare("DELETE FROM dependent_send_queue_events WHERE room_id = ?")? + .execute((room_id,))?; + Ok(()) + } } #[async_trait] @@ -1726,6 +1733,10 @@ impl StateStore for SqliteStateStore { let send_queue_room_id = this.encode_key(keys::SEND_QUEUE, &room_id); txn.remove_room_send_queue(&send_queue_room_id)?; + let dependent_send_queue_room_id = + this.encode_key(keys::DEPENDENTS_SEND_QUEUE, &room_id); + txn.remove_room_dependent_send_queue(&dependent_send_queue_room_id)?; + Ok(()) }) .await