Room deletion (fixes #43)
This commit is contained in:
@@ -9,12 +9,13 @@ use serde_json::json;
|
||||
use tuwunel_core::{
|
||||
Event, Result, err,
|
||||
matrix::pdu::{PduCount, PduEvent, PduId, RawPduId},
|
||||
trace,
|
||||
utils::{
|
||||
ReadyExt,
|
||||
stream::{TryIgnore, WidebandExt},
|
||||
},
|
||||
};
|
||||
use tuwunel_database::{Deserialized, Map};
|
||||
use tuwunel_database::{Deserialized, Interfix, Map};
|
||||
|
||||
pub struct Service {
|
||||
db: Data,
|
||||
@@ -191,4 +192,20 @@ impl Service {
|
||||
.await
|
||||
.deserialized()
|
||||
}
|
||||
|
||||
pub(super) async fn delete_all_rooms_threads(&self, room_id: &RoomId) -> Result {
|
||||
let prefix = (room_id, Interfix);
|
||||
|
||||
self.db
|
||||
.threadid_userids
|
||||
.keys_prefix_raw(&prefix)
|
||||
.ignore_err()
|
||||
.ready_for_each(|key| {
|
||||
trace!("Removing key: {key:?}");
|
||||
self.db.threadid_userids.remove(key);
|
||||
})
|
||||
.await;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user