1
0
Fork 0
mirror of https://gitlab.com/famedly/conduit.git synced 2025-08-01 17:38:36 +00:00
conduit/src/service/rooms/edus/read_receipt/mod.rs

65 lines
1.8 KiB
Rust
Raw Normal View History

mod data;
2022-10-08 13:04:55 +02:00
pub use data::Data;
2022-09-07 13:25:51 +02:00
use crate::{services, Result};
2022-10-09 17:25:06 +02:00
use ruma::{events::receipt::ReceiptEvent, serde::Raw, OwnedUserId, RoomId, UserId};
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 {
/// Replaces the previous read receipt.
pub fn readreceipt_update(
&self,
user_id: &UserId,
room_id: &RoomId,
event: ReceiptEvent,
) -> Result<()> {
self.db.readreceipt_update(user_id, room_id, event)
}
/// Returns an iterator over the most recent read_receipts in a room that happened after the event with id `since`.
2021-02-28 12:41:03 +01:00
#[tracing::instrument(skip(self))]
2021-06-08 18:10:00 +02:00
pub fn readreceipts_since<'a>(
&'a self,
room_id: &RoomId,
since: u64,
2021-11-26 20:36:40 +01:00
) -> impl Iterator<
Item = Result<(
2022-10-09 17:25:06 +02:00
OwnedUserId,
2021-11-26 20:36:40 +01:00
u64,
Raw<ruma::events::AnySyncEphemeralRoomEvent>,
)>,
> + 'a {
self.db.readreceipts_since(room_id, since)
}
/// Sets a private read marker at `shorteventid`.
#[tracing::instrument(skip(self))]
pub fn private_read_set(
&self,
room_id: &RoomId,
user_id: &UserId,
shorteventid: u64,
) -> Result<()> {
self.db.private_read_set(room_id, user_id, shorteventid)?;
services()
.rooms
.user
.update_notification_counts(user_id, room_id)
}
/// Returns the private read marker.
2021-02-28 12:41:03 +01:00
#[tracing::instrument(skip(self))]
pub fn private_read_get(&self, room_id: &RoomId, user_id: &UserId) -> Result<Option<u64>> {
self.db.private_read_get(room_id, user_id)
}
/// Returns the count of the last typing update in this room.
pub fn last_privateread_update(&self, user_id: &UserId, room_id: &RoomId) -> Result<u64> {
self.db.last_privateread_update(user_id, room_id)
}
}