revolt_database/models/channel_unreads/
ops.rs

1use revolt_result::Result;
2
3use crate::ChannelUnread;
4
5#[cfg(feature = "mongodb")]
6mod mongodb;
7mod reference;
8
9#[async_trait]
10pub trait AbstractChannelUnreads: Sync + Send {
11    /// Acknowledge a message, and returns updated channel unread.
12    async fn acknowledge_message(
13        &self,
14        channel_id: &str,
15        user_id: &str,
16        message_id: &str,
17    ) -> Result<Option<ChannelUnread>>;
18
19    /// Acknowledge many channels.
20    async fn acknowledge_channels(&self, user_id: &str, channel_ids: &[String]) -> Result<()>;
21
22    /// Add a mention.
23    async fn add_mention_to_unread<'a>(
24        &self,
25        channel_id: &str,
26        user_id: &str,
27        message_ids: &[String],
28    ) -> Result<()>;
29
30    /// Add a mention.
31    async fn add_mention_to_many_unreads<'a>(
32        &self,
33        channel_id: &str,
34        user_ids: &[String],
35        message_ids: &[String],
36    ) -> Result<()>;
37
38    /// Fetch all unreads with mentions for a user.
39    async fn fetch_unread_mentions(&self, user_id: &str) -> Result<Vec<ChannelUnread>>;
40
41    /// Fetch all channel unreads for a user.
42    async fn fetch_unreads(&self, user_id: &str) -> Result<Vec<ChannelUnread>>;
43
44    /// Fetch unread for a specific user in a channel.
45    async fn fetch_unread(&self, user_id: &str, channel_id: &str) -> Result<Option<ChannelUnread>>;
46}