revolt_database/models/messages/
ops.rs

1use revolt_result::Result;
2
3use crate::{AppendMessage, FieldsMessage, Message, MessageQuery, PartialMessage};
4
5mod mongodb;
6mod reference;
7
8#[async_trait]
9pub trait AbstractMessages: Sync + Send {
10    /// Insert a new message into the database
11    async fn insert_message(&self, message: &Message) -> Result<()>;
12
13    /// Fetch a message by its id
14    async fn fetch_message(&self, id: &str) -> Result<Message>;
15
16    /// Fetch multiple messages by given query
17    async fn fetch_messages(&self, query: MessageQuery) -> Result<Vec<Message>>;
18
19    /// Fetch multiple messages by given IDs
20    async fn fetch_messages_by_id(&self, ids: &[String]) -> Result<Vec<Message>>;
21
22    /// Update a given message with new information
23    async fn update_message(&self, id: &str, message: &PartialMessage, remove: Vec<FieldsMessage>) -> Result<()>;
24
25    /// Append information to a given message
26    async fn append_message(&self, id: &str, append: &AppendMessage) -> Result<()>;
27
28    /// Add a new reaction to a message
29    async fn add_reaction(&self, id: &str, emoji: &str, user: &str) -> Result<()>;
30
31    /// Remove a reaction from a message
32    async fn remove_reaction(&self, id: &str, emoji: &str, user: &str) -> Result<()>;
33
34    /// Remove reaction from a message
35    async fn clear_reaction(&self, id: &str, emoji: &str) -> Result<()>;
36
37    /// Delete a message from the database by its id
38    async fn delete_message(&self, id: &str) -> Result<()>;
39
40    /// Delete messages from a channel by their ids and corresponding channel id
41    async fn delete_messages(&self, channel: &str, ids: &[String]) -> Result<()>;
42}