2022-06-25 16:12:23 +02:00
|
|
|
mod data;
|
2022-10-08 13:04:55 +02:00
|
|
|
|
2024-04-22 23:48:57 -04:00
|
|
|
pub(crate) use data::Data;
|
2022-10-09 17:25:06 +02:00
|
|
|
use ruma::{OwnedRoomId, RoomId};
|
2020-05-03 17:25:31 +02:00
|
|
|
|
2022-09-07 13:25:51 +02:00
|
|
|
use crate::Result;
|
2020-05-03 17:25:31 +02:00
|
|
|
|
2024-04-22 23:48:57 -04:00
|
|
|
pub(crate) struct Service {
|
|
|
|
|
pub(crate) db: &'static dyn Data,
|
2022-06-25 16:12:23 +02:00
|
|
|
}
|
2021-08-12 23:04:00 +02:00
|
|
|
|
2022-10-05 12:45:54 +02:00
|
|
|
impl Service {
|
2022-06-25 16:12:23 +02:00
|
|
|
/// Checks if a room exists.
|
|
|
|
|
#[tracing::instrument(skip(self))]
|
2024-04-22 23:48:57 -04:00
|
|
|
pub(crate) fn exists(&self, room_id: &RoomId) -> Result<bool> { self.db.exists(room_id) }
|
2024-03-05 19:48:54 -05:00
|
|
|
|
2024-04-22 23:48:57 -04:00
|
|
|
pub(crate) fn iter_ids<'a>(&'a self) -> Box<dyn Iterator<Item = Result<OwnedRoomId>> + 'a> { self.db.iter_ids() }
|
2024-03-05 19:48:54 -05:00
|
|
|
|
2024-04-22 23:48:57 -04:00
|
|
|
pub(crate) fn is_disabled(&self, room_id: &RoomId) -> Result<bool> { self.db.is_disabled(room_id) }
|
2024-03-05 19:48:54 -05:00
|
|
|
|
2024-04-22 23:48:57 -04:00
|
|
|
pub(crate) fn disable_room(&self, room_id: &RoomId, disabled: bool) -> Result<()> {
|
2022-10-05 18:36:12 +02:00
|
|
|
self.db.disable_room(room_id, disabled)
|
|
|
|
|
}
|
2024-03-05 19:48:54 -05:00
|
|
|
|
2024-04-22 23:48:57 -04:00
|
|
|
pub(crate) fn is_banned(&self, room_id: &RoomId) -> Result<bool> { self.db.is_banned(room_id) }
|
2024-03-05 19:48:54 -05:00
|
|
|
|
2024-04-22 23:48:57 -04:00
|
|
|
pub(crate) fn ban_room(&self, room_id: &RoomId, banned: bool) -> Result<()> { self.db.ban_room(room_id, banned) }
|
2024-03-05 19:48:54 -05:00
|
|
|
|
2024-04-22 23:48:57 -04:00
|
|
|
pub(crate) fn list_banned_rooms<'a>(&'a self) -> Box<dyn Iterator<Item = Result<OwnedRoomId>> + 'a> {
|
2024-02-18 18:57:17 -05:00
|
|
|
self.db.list_banned_rooms()
|
|
|
|
|
}
|
2022-06-25 16:12:23 +02:00
|
|
|
}
|