feat(safety): fetch reports and fetch snapshot API

This commit is contained in:
Paul Makles
2023-03-01 11:22:22 +00:00
parent 42b4906594
commit 304336d905
13 changed files with 93 additions and 4 deletions

View File

@@ -0,0 +1,17 @@
use revolt_quark::models::{Snapshot, User};
use revolt_quark::{Db, Error, Result};
use rocket::serde::json::Json;
/// # Fetch Snapshot
///
/// Fetch a snapshot for a given report
#[openapi(tag = "User Safety")]
#[get("/snapshot/<report_id>")]
pub async fn fetch_snapshot(db: &Db, user: User, report_id: String) -> Result<Json<Snapshot>> {
// Must be privileged for this route
if !user.privileged {
return Err(Error::NotPrivileged);
}
db.fetch_snapshot(&report_id).await.map(Json)
}