Room deletion (fixes #43)

This commit is contained in:
dasha_uwu
2025-08-22 20:21:05 +05:00
parent 7a3496869b
commit d05d3f710f
15 changed files with 447 additions and 7 deletions

View File

@@ -7,12 +7,13 @@ use tuwunel_core::{
arrayvec::ArrayVec,
implement,
matrix::event::{Event, Matches},
trace,
utils::{
ArrayVecExt, IterStream, ReadyExt, set,
stream::{TryIgnore, WidebandExt},
},
};
use tuwunel_database::{Map, keyval::Val};
use tuwunel_database::{Interfix, Map, keyval::Val};
use crate::rooms::{
short::ShortRoomId,
@@ -197,6 +198,23 @@ fn search_pdu_ids_query_word(
.ready_take_while(move |key| key.starts_with(&prefix))
}
#[implement(Service)]
pub async fn delete_all_search_tokenids_for_room(&self, room_id: &RoomId) -> Result {
let prefix = (room_id, Interfix);
self.db
.tokenids
.keys_prefix_raw(&prefix)
.ignore_err()
.ready_for_each(|key| {
trace!("Removing key: {key:?}");
self.db.tokenids.remove(key);
})
.await;
Ok(())
}
/// Splits a string into tokens used as keys in the search inverted index
///
/// This may be used to tokenize both message bodies (for indexing) or search