unfinished untested impl of room deletion

Signed-off-by: strawberry <strawberry@puppygock.gay>
This commit is contained in:
strawberry
2024-02-20 22:40:46 -05:00
parent 0593dce8a6
commit a94bf2cf9f
31 changed files with 400 additions and 9 deletions
+13
View File
@@ -1,4 +1,5 @@
use ruma::RoomId;
use tracing::debug;
use crate::{database::KeyValueDatabase, service, services, utils, Result};
@@ -22,6 +23,18 @@ impl service::rooms::search::Data for KeyValueDatabase {
self.tokenids.insert_batch(&mut batch)
}
fn delete_all_search_tokenids_for_room(&self, room_id: &RoomId) -> Result<()> {
let mut prefix = room_id.as_bytes().to_vec();
prefix.push(0xff);
for (key, _) in self.tokenids.scan_prefix(prefix) {
debug!("Removing key: {:?}", key);
self.tokenids.remove(&key)?;
}
Ok(())
}
fn search_pdus<'a>(&'a self, room_id: &RoomId, search_string: &str) -> SearchPdusResult<'a> {
let prefix = services()
.rooms