revolt_database/models/sessions/
ops.rs1use iso8601_timestamp::Timestamp;
2use revolt_result::Result;
3
4use crate::Session;
5
6#[cfg(feature = "mongodb")]
7mod mongodb;
8mod reference;
9
10#[async_trait]
11pub trait AbstractSessions: Sync + Send {
12 async fn fetch_session(&self, id: &str) -> Result<Session>;
14
15 async fn fetch_sessions(&self, user_id: &str) -> Result<Vec<Session>>;
17
18 async fn fetch_sessions_with_subscription(&self, user_ids: &[String]) -> Result<Vec<Session>>;
20
21 async fn fetch_session_by_token(&self, token: &str) -> Result<Session>;
23
24 async fn save_session(&self, session: &Session) -> Result<()>;
26
27 async fn delete_session(&self, id: &str) -> Result<()>;
29
30 async fn delete_all_sessions(&self, user_id: &str, ignore: Option<String>) -> Result<()>;
32
33 async fn remove_push_subscription_by_session_id(&self, session_id: &str) -> Result<()>;
35
36 async fn update_session_last_seen(&self, session_id: &str, when: Timestamp) -> Result<()>;
37}