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

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

37 lines
1,001 B
Rust
Raw Normal View History

mod data;
2022-10-08 13:04:55 +02:00
use std::sync::Arc;
use data::Data;
2022-10-09 17:25:06 +02:00
use ruma::{OwnedRoomId, RoomId};
2022-09-07 13:25:51 +02:00
use crate::Result;
pub struct Service {
pub db: Arc<dyn Data>,
}
2021-08-12 23:04:00 +02:00
2022-10-05 12:45:54 +02:00
impl Service {
/// 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()
}
}