Files
continuwuity/src/service/rooms/user/mod.rs
T

49 lines
1.4 KiB
Rust
Raw Normal View History

mod data;
2022-10-08 13:04:55 +02:00
pub use data::Data;
2022-10-09 17:25:06 +02:00
use ruma::{OwnedRoomId, OwnedUserId, RoomId, UserId};
2022-02-08 09:25:44 +01:00
2022-09-07 13:25:51 +02:00
use crate::Result;
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-10-05 12:45:54 +02:00
impl Service {
pub fn reset_notification_counts(&self, user_id: &UserId, room_id: &RoomId) -> Result<()> {
self.db.reset_notification_counts(user_id, room_id)
}
pub fn notification_count(&self, user_id: &UserId, room_id: &RoomId) -> Result<u64> {
self.db.notification_count(user_id, room_id)
}
pub fn highlight_count(&self, user_id: &UserId, room_id: &RoomId) -> Result<u64> {
self.db.highlight_count(user_id, room_id)
}
pub fn last_notification_read(&self, user_id: &UserId, room_id: &RoomId) -> Result<u64> {
self.db.last_notification_read(user_id, room_id)
}
pub fn associate_token_shortstatehash(
&self,
room_id: &RoomId,
token: u64,
shortstatehash: u64,
) -> Result<()> {
2022-10-05 20:34:31 +02:00
self.db
.associate_token_shortstatehash(room_id, token, shortstatehash)
}
pub fn get_token_shortstatehash(&self, room_id: &RoomId, token: u64) -> Result<Option<u64>> {
self.db.get_token_shortstatehash(room_id, token)
}
2020-08-21 21:22:59 +02:00
pub fn get_shared_rooms<'a>(
&'a self,
2022-10-09 17:25:06 +02:00
users: Vec<OwnedUserId>,
) -> Result<impl Iterator<Item = Result<OwnedRoomId>> + 'a> {
self.db.get_shared_rooms(users)
2020-08-18 12:15:27 +02:00
}
}