2022-06-25 16:12:23 +02:00
|
|
|
mod data;
|
2022-10-08 13:04:55 +02:00
|
|
|
|
2024-05-09 15:59:08 -07:00
|
|
|
use std::sync::Arc;
|
|
|
|
|
|
2024-05-26 21:29:19 +00:00
|
|
|
use data::Data;
|
2022-10-09 17:25:06 +02:00
|
|
|
use ruma::{OwnedRoomId, RoomId};
|
2022-06-25 16:12:23 +02:00
|
|
|
|
2022-09-07 13:25:51 +02:00
|
|
|
use crate::Result;
|
2022-06-25 16:12:23 +02:00
|
|
|
|
2024-05-09 15:59:08 -07:00
|
|
|
pub struct Service {
|
2024-05-27 03:17:20 +00:00
|
|
|
db: Data,
|
2022-06-25 16:12:23 +02:00
|
|
|
}
|
|
|
|
|
|
2024-07-04 03:26:19 +00:00
|
|
|
impl crate::Service for Service {
|
|
|
|
|
fn build(args: crate::Args<'_>) -> Result<Arc<Self>> {
|
|
|
|
|
Ok(Arc::new(Self {
|
|
|
|
|
db: Data::new(args.db),
|
|
|
|
|
}))
|
2024-05-27 03:17:20 +00:00
|
|
|
}
|
|
|
|
|
|
2024-07-04 03:26:19 +00:00
|
|
|
fn name(&self) -> &str { crate::service::make_name(std::module_path!()) }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl Service {
|
2024-07-07 19:03:15 +00:00
|
|
|
#[tracing::instrument(skip(self), level = "debug")]
|
2024-05-09 15:59:08 -07:00
|
|
|
pub fn set_public(&self, room_id: &RoomId) -> Result<()> { self.db.set_public(room_id) }
|
2020-05-25 23:24:13 +02:00
|
|
|
|
2024-07-07 19:03:15 +00:00
|
|
|
#[tracing::instrument(skip(self), level = "debug")]
|
2024-05-09 15:59:08 -07:00
|
|
|
pub fn set_not_public(&self, room_id: &RoomId) -> Result<()> { self.db.set_not_public(room_id) }
|
2020-05-25 23:24:13 +02:00
|
|
|
|
2024-07-07 19:03:15 +00:00
|
|
|
#[tracing::instrument(skip(self), level = "debug")]
|
2024-05-09 15:59:08 -07:00
|
|
|
pub fn is_public_room(&self, room_id: &RoomId) -> Result<bool> { self.db.is_public_room(room_id) }
|
2020-05-25 23:24:13 +02:00
|
|
|
|
2024-07-07 19:03:15 +00:00
|
|
|
#[tracing::instrument(skip(self), level = "debug")]
|
2024-05-09 15:59:08 -07:00
|
|
|
pub fn public_rooms(&self) -> impl Iterator<Item = Result<OwnedRoomId>> + '_ { self.db.public_rooms() }
|
2022-06-25 16:12:23 +02:00
|
|
|
}
|