conduwuit/src/service/rooms/metadata/mod.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

43 lines
1.1 KiB
Rust
Raw Normal View History

mod data;
2022-10-08 13:04:55 +02:00
use std::sync::Arc;
use conduit::{Result, Server};
use data::Data;
use database::Database;
2022-10-09 17:25:06 +02:00
use ruma::{OwnedRoomId, RoomId};
pub struct Service {
db: Data,
}
2021-08-12 23:04:00 +02:00
2022-10-05 12:45:54 +02:00
impl Service {
pub fn build(_server: &Arc<Server>, db: &Arc<Database>) -> Result<Self> {
Ok(Self {
db: Data::new(db),
})
}
/// Checks if a room exists.
#[tracing::instrument(skip(self))]
pub fn exists(&self, room_id: &RoomId) -> Result<bool> { self.db.exists(room_id) }
#[must_use]
pub fn iter_ids<'a>(&'a self) -> Box<dyn Iterator<Item = Result<OwnedRoomId>> + 'a> { self.db.iter_ids() }
pub fn is_disabled(&self, room_id: &RoomId) -> Result<bool> { self.db.is_disabled(room_id) }
pub 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)
}
pub fn is_banned(&self, room_id: &RoomId) -> Result<bool> { self.db.is_banned(room_id) }
pub fn ban_room(&self, room_id: &RoomId, banned: bool) -> Result<()> { self.db.ban_room(room_id, banned) }
#[must_use]
pub fn list_banned_rooms<'a>(&'a self) -> Box<dyn Iterator<Item = Result<OwnedRoomId>> + 'a> {
self.db.list_banned_rooms()
}
}