2022-06-25 16:12:23 +02:00
|
|
|
mod data;
|
2022-10-08 13:04:55 +02:00
|
|
|
|
2022-06-25 16:12:23 +02:00
|
|
|
pub use data::Data;
|
2022-09-07 13:25:51 +02:00
|
|
|
|
|
|
|
use crate::Result;
|
2022-10-05 20:34:31 +02:00
|
|
|
use ruma::{RoomAliasId, RoomId};
|
2022-06-25 16:12:23 +02:00
|
|
|
|
2022-10-05 12:45:54 +02:00
|
|
|
pub struct Service {
|
2022-10-08 13:02:52 +02:00
|
|
|
pub db: &'static dyn Data,
|
2022-06-25 16:12:23 +02:00
|
|
|
}
|
|
|
|
|
2022-10-05 12:45:54 +02:00
|
|
|
impl Service {
|
2022-09-06 23:15:09 +02:00
|
|
|
#[tracing::instrument(skip(self))]
|
2022-10-05 20:34:31 +02:00
|
|
|
pub fn set_alias(&self, alias: &RoomAliasId, room_id: &RoomId) -> Result<()> {
|
2022-06-25 16:12:23 +02:00
|
|
|
self.db.set_alias(alias, room_id)
|
|
|
|
}
|
2020-05-25 23:24:13 +02:00
|
|
|
|
2022-09-06 23:15:09 +02:00
|
|
|
#[tracing::instrument(skip(self))]
|
2022-10-05 20:34:31 +02:00
|
|
|
pub fn remove_alias(&self, alias: &RoomAliasId) -> Result<()> {
|
2022-06-25 16:12:23 +02:00
|
|
|
self.db.remove_alias(alias)
|
2020-05-25 23:24:13 +02:00
|
|
|
}
|
|
|
|
|
2021-07-29 08:36:01 +02:00
|
|
|
#[tracing::instrument(skip(self))]
|
2022-06-25 16:12:23 +02:00
|
|
|
pub fn resolve_local_alias(&self, alias: &RoomAliasId) -> Result<Option<Box<RoomId>>> {
|
2022-09-07 13:25:51 +02:00
|
|
|
self.db.resolve_local_alias(alias)
|
2020-05-25 23:24:13 +02:00
|
|
|
}
|
|
|
|
|
2021-07-29 08:36:01 +02:00
|
|
|
#[tracing::instrument(skip(self))]
|
2022-06-25 16:12:23 +02:00
|
|
|
pub fn local_aliases_for_room<'a>(
|
2021-06-08 18:10:00 +02:00
|
|
|
&'a self,
|
|
|
|
room_id: &RoomId,
|
2022-10-08 13:02:52 +02:00
|
|
|
) -> Box<dyn Iterator<Item = Result<Box<RoomAliasId>>> + 'a> {
|
2022-06-25 16:12:23 +02:00
|
|
|
self.db.local_aliases_for_room(room_id)
|
2020-05-25 23:24:13 +02:00
|
|
|
}
|
2022-06-25 16:12:23 +02:00
|
|
|
}
|