2022-08-14 13:38:21 +02:00
|
|
|
mod data;
|
2022-10-08 13:04:55 +02:00
|
|
|
|
2024-04-22 23:48:57 -04:00
|
|
|
pub(crate) use data::Data;
|
2022-10-09 17:25:06 +02:00
|
|
|
use ruma::{OwnedRoomId, OwnedUserId, RoomId, UserId};
|
2021-04-12 12:40:16 +02:00
|
|
|
|
2022-09-07 13:25:51 +02:00
|
|
|
use crate::Result;
|
2021-04-12 12:40:16 +02:00
|
|
|
|
2024-04-22 23:48:57 -04:00
|
|
|
pub(crate) struct Service {
|
|
|
|
pub(crate) db: &'static dyn Data,
|
2022-08-14 13:38:21 +02:00
|
|
|
}
|
2021-04-13 15:00:45 +02:00
|
|
|
|
2022-10-05 12:45:54 +02:00
|
|
|
impl Service {
|
2024-04-22 23:48:57 -04:00
|
|
|
pub(crate) fn reset_notification_counts(&self, user_id: &UserId, room_id: &RoomId) -> Result<()> {
|
2024-03-05 19:48:54 -05:00
|
|
|
self.db.reset_notification_counts(user_id, room_id)
|
|
|
|
}
|
|
|
|
|
2024-04-22 23:48:57 -04:00
|
|
|
pub(crate) fn notification_count(&self, user_id: &UserId, room_id: &RoomId) -> Result<u64> {
|
2024-03-05 19:48:54 -05:00
|
|
|
self.db.notification_count(user_id, room_id)
|
|
|
|
}
|
|
|
|
|
2024-04-22 23:48:57 -04:00
|
|
|
pub(crate) fn highlight_count(&self, user_id: &UserId, room_id: &RoomId) -> Result<u64> {
|
2024-03-05 19:48:54 -05:00
|
|
|
self.db.highlight_count(user_id, room_id)
|
|
|
|
}
|
|
|
|
|
2024-04-22 23:48:57 -04:00
|
|
|
pub(crate) fn last_notification_read(&self, user_id: &UserId, room_id: &RoomId) -> Result<u64> {
|
2024-03-05 19:48:54 -05:00
|
|
|
self.db.last_notification_read(user_id, room_id)
|
|
|
|
}
|
|
|
|
|
2024-04-22 23:48:57 -04:00
|
|
|
pub(crate) fn associate_token_shortstatehash(
|
|
|
|
&self, room_id: &RoomId, token: u64, shortstatehash: u64,
|
|
|
|
) -> Result<()> {
|
2024-03-25 17:05:11 -04:00
|
|
|
self.db
|
|
|
|
.associate_token_shortstatehash(room_id, token, shortstatehash)
|
2024-03-05 19:48:54 -05:00
|
|
|
}
|
|
|
|
|
2024-04-22 23:48:57 -04:00
|
|
|
pub(crate) fn get_token_shortstatehash(&self, room_id: &RoomId, token: u64) -> Result<Option<u64>> {
|
2024-03-05 19:48:54 -05:00
|
|
|
self.db.get_token_shortstatehash(room_id, token)
|
|
|
|
}
|
|
|
|
|
2024-04-22 23:48:57 -04:00
|
|
|
pub(crate) fn get_shared_rooms(
|
|
|
|
&self, users: Vec<OwnedUserId>,
|
|
|
|
) -> Result<impl Iterator<Item = Result<OwnedRoomId>>> {
|
2024-03-05 19:48:54 -05:00
|
|
|
self.db.get_shared_rooms(users)
|
|
|
|
}
|
2022-08-14 13:38:21 +02:00
|
|
|
}
|