Merge branch 'master' into webhooks
This commit is contained in:
6
crates/quark/src/traits/admin/stats.rs
Normal file
6
crates/quark/src/traits/admin/stats.rs
Normal file
@@ -0,0 +1,6 @@
|
||||
use crate::{models::stats::Stats, Result};
|
||||
|
||||
#[async_trait]
|
||||
pub trait AbstractStats: Sync + Send {
|
||||
async fn generate_stats(&self) -> Result<Stats>;
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
use crate::models::message::{AppendMessage, Message, MessageSort, PartialMessage};
|
||||
use crate::models::message::{AppendMessage, Message, MessageQuery, PartialMessage};
|
||||
use crate::Result;
|
||||
|
||||
#[async_trait]
|
||||
@@ -21,27 +21,8 @@ pub trait AbstractMessage: Sync + Send {
|
||||
/// Delete messages from a channel by their ids and corresponding channel id
|
||||
async fn delete_messages(&self, channel: &str, ids: Vec<String>) -> Result<()>;
|
||||
|
||||
/// Fetch multiple messages
|
||||
async fn fetch_messages(
|
||||
&self,
|
||||
channel: &str,
|
||||
limit: Option<i64>,
|
||||
before: Option<String>,
|
||||
after: Option<String>,
|
||||
sort: Option<MessageSort>,
|
||||
nearby: Option<String>,
|
||||
) -> Result<Vec<Message>>;
|
||||
|
||||
/// Search for messages
|
||||
async fn search_messages(
|
||||
&self,
|
||||
channel: &str,
|
||||
query: &str,
|
||||
limit: Option<i64>,
|
||||
before: Option<String>,
|
||||
after: Option<String>,
|
||||
sort: MessageSort,
|
||||
) -> Result<Vec<Message>>;
|
||||
/// Fetch multiple messages by given query
|
||||
async fn fetch_messages(&self, query: MessageQuery) -> Result<Vec<Message>>;
|
||||
|
||||
/// Add a new reaction to a message
|
||||
async fn add_reaction(&self, id: &str, emoji: &str, user: &str) -> Result<()>;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
mod admin {
|
||||
pub mod migrations;
|
||||
pub mod stats;
|
||||
}
|
||||
|
||||
mod media {
|
||||
@@ -33,6 +34,7 @@ mod safety {
|
||||
}
|
||||
|
||||
pub use admin::migrations::AbstractMigrations;
|
||||
pub use admin::stats::AbstractStats;
|
||||
|
||||
pub use media::attachment::AbstractAttachment;
|
||||
pub use media::emoji::AbstractEmoji;
|
||||
@@ -58,6 +60,7 @@ pub trait AbstractDatabase:
|
||||
Sync
|
||||
+ Send
|
||||
+ AbstractMigrations
|
||||
+ AbstractStats
|
||||
+ AbstractAttachment
|
||||
+ AbstractEmoji
|
||||
+ AbstractChannel
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
use crate::models::report::PartialReport;
|
||||
use crate::models::Report;
|
||||
use crate::Result;
|
||||
|
||||
@@ -5,4 +6,13 @@ use crate::Result;
|
||||
pub trait AbstractReport: Sync + Send {
|
||||
/// Insert a new report into the database
|
||||
async fn insert_report(&self, report: &Report) -> Result<()>;
|
||||
|
||||
/// Update a given report with new information
|
||||
async fn update_report(&self, id: &str, message: &PartialReport) -> Result<()>;
|
||||
|
||||
/// Fetch report
|
||||
async fn fetch_report(&self, report_id: &str) -> Result<Report>;
|
||||
|
||||
/// Fetch reports
|
||||
async fn fetch_reports(&self) -> Result<Vec<Report>>;
|
||||
}
|
||||
|
||||
@@ -5,4 +5,7 @@ use crate::Result;
|
||||
pub trait AbstractSnapshot: Sync + Send {
|
||||
/// Insert a new snapshot into the database
|
||||
async fn insert_snapshot(&self, snapshot: &Snapshot) -> Result<()>;
|
||||
|
||||
/// Fetch a snapshot by a report's id
|
||||
async fn fetch_snapshot(&self, report_id: &str) -> Result<Snapshot>;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user