revolt_database/models/messages/
ops.rs1use std::collections::HashMap;
2use std::time::SystemTime;
3use revolt_result::Result;
4
5use crate::{AppendMessage, FieldsMessage, Message, MessageQuery, PartialMessage};
6
7#[cfg(feature = "mongodb")]
8mod mongodb;
9mod reference;
10
11#[async_trait]
12pub trait AbstractMessages: Sync + Send {
13 async fn insert_message(&self, message: &Message) -> Result<()>;
15
16 async fn fetch_message(&self, id: &str) -> Result<Message>;
18
19 async fn fetch_messages(&self, query: MessageQuery) -> Result<Vec<Message>>;
21
22 async fn fetch_messages_by_id(&self, ids: &[String]) -> Result<Vec<Message>>;
24
25 async fn update_message(&self, id: &str, message: &PartialMessage, remove: Vec<FieldsMessage>) -> Result<()>;
27
28 async fn append_message(&self, id: &str, append: &AppendMessage) -> Result<()>;
30
31 async fn add_reaction(&self, id: &str, emoji: &str, user: &str) -> Result<()>;
33
34 async fn remove_reaction(&self, id: &str, emoji: &str, user: &str) -> Result<()>;
36
37 async fn clear_reaction(&self, id: &str, emoji: &str) -> Result<()>;
39
40 async fn delete_message(&self, id: &str) -> Result<()>;
42
43 async fn delete_messages(&self, channel: &str, ids: &[String]) -> Result<()>;
45
46 async fn delete_messages_by_author_since(
48 &self,
49 channels: &[String],
50 author: &str,
51 since: SystemTime
52 ) -> Result<HashMap<String, Vec<String>>>;
53}