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

@@ -4,7 +4,7 @@ use futures::{Stream, StreamExt};
use ruma::{EventId, RoomId, events::StateEventType};
use serde::Deserialize;
pub use tuwunel_core::matrix::pdu::{ShortEventId, ShortId, ShortRoomId, ShortStateKey};
use tuwunel_core::{Result, err, implement, matrix::StateKey, utils, utils::IterStream};
use tuwunel_core::{Err, Result, err, implement, matrix::StateKey, utils, utils::IterStream};
use tuwunel_database::{Deserialized, Get, Map, Qry};
pub struct Service {
@@ -258,3 +258,19 @@ pub async fn get_or_create_shortroomid(&self, room_id: &RoomId) -> ShortRoomId {
*short
})
}
#[implement(Service)]
pub async fn delete_shortroomid(&self, room_id: &RoomId) -> Result {
if self
.db
.roomid_shortroomid
.exists(room_id)
.await
.is_ok()
{
self.db.roomid_shortroomid.remove(room_id);
Ok(())
} else {
Err!(Database("not found"))
}
}