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 -1
View File
@@ -3,7 +3,7 @@ use std::{collections::hash_map, mem::size_of, sync::Arc};
use ruma::{
api::client::error::ErrorKind, CanonicalJsonObject, EventId, OwnedUserId, RoomId, UserId,
};
use tracing::error;
use tracing::{debug, error};
use crate::{
database::KeyValueDatabase,
@@ -303,6 +303,18 @@ impl service::rooms::timeline::Data for KeyValueDatabase {
.increment_batch(&mut highlights_batch.into_iter())?;
Ok(())
}
fn delete_all_pdus_for_room(&self, room_id: &RoomId) -> Result<()> {
let mut prefix = room_id.as_bytes().to_vec();
prefix.push(0xff);
for (key, _) in self.pduid_pdu.scan_prefix(prefix) {
debug!("Removing key: {:?}", key);
self.pduid_pdu.remove(&key)?;
}
Ok(())
}
}
/// Returns the `count` of this pdu's id.