feat: add route to fetch user flags
chore: bump rauth to change disabled account behaviour
This commit is contained in:
@@ -52,7 +52,7 @@ mobc-redis = { version = "0.7.0", default-features = false, features = ["async-s
|
|||||||
# web
|
# web
|
||||||
rocket = { version = "0.5.0-rc.2", default-features = false, features = ["json"] }
|
rocket = { version = "0.5.0-rc.2", default-features = false, features = ["json"] }
|
||||||
rocket_empty = { version = "0.1.1", features = ["schema"] }
|
rocket_empty = { version = "0.1.1", features = ["schema"] }
|
||||||
rocket_rauth = { git = "https://github.com/insertish/rauth", tag = "1.0.3" }
|
rocket_rauth = { git = "https://github.com/insertish/rauth", tag = "1.0.4" }
|
||||||
|
|
||||||
# spec generation
|
# spec generation
|
||||||
schemars = "0.8.8"
|
schemars = "0.8.8"
|
||||||
|
|||||||
26
crates/delta/src/routes/users/fetch_user_flags.rs
Normal file
26
crates/delta/src/routes/users/fetch_user_flags.rs
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
use revolt_quark::{Database, Ref, Result};
|
||||||
|
|
||||||
|
use rocket::{serde::json::Json, State};
|
||||||
|
use serde::Serialize;
|
||||||
|
|
||||||
|
/// # Flag Response
|
||||||
|
#[derive(Serialize, JsonSchema)]
|
||||||
|
pub struct FlagResponse {
|
||||||
|
/// Flags
|
||||||
|
flags: i32,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// # Fetch User Flags
|
||||||
|
///
|
||||||
|
/// Retrieve a user's flags.
|
||||||
|
#[openapi(tag = "User Information")]
|
||||||
|
#[get("/<target>/flags")]
|
||||||
|
pub async fn fetch_user_flags(db: &State<Database>, target: Ref) -> Result<Json<FlagResponse>> {
|
||||||
|
let flags = if let Ok(target) = target.as_user(db).await {
|
||||||
|
target.flags.unwrap_or_default()
|
||||||
|
} else {
|
||||||
|
0
|
||||||
|
};
|
||||||
|
|
||||||
|
Ok(Json(FlagResponse { flags }))
|
||||||
|
}
|
||||||
@@ -9,6 +9,7 @@ mod fetch_dms;
|
|||||||
mod fetch_profile;
|
mod fetch_profile;
|
||||||
mod fetch_self;
|
mod fetch_self;
|
||||||
mod fetch_user;
|
mod fetch_user;
|
||||||
|
mod fetch_user_flags;
|
||||||
mod find_mutual;
|
mod find_mutual;
|
||||||
mod get_default_avatar;
|
mod get_default_avatar;
|
||||||
mod open_dm;
|
mod open_dm;
|
||||||
@@ -21,6 +22,7 @@ pub fn routes() -> (Vec<Route>, OpenApi) {
|
|||||||
// User Information
|
// User Information
|
||||||
fetch_self::req,
|
fetch_self::req,
|
||||||
fetch_user::req,
|
fetch_user::req,
|
||||||
|
fetch_user_flags::fetch_user_flags,
|
||||||
edit_user::req,
|
edit_user::req,
|
||||||
change_username::req,
|
change_username::req,
|
||||||
get_default_avatar::req,
|
get_default_avatar::req,
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ rocket_empty = { version = "0.1.1", optional = true, features = [ "schema" ] }
|
|||||||
rocket_cors = { optional = true, git = "https://github.com/lawliet89/rocket_cors", rev = "c17e8145baa4790319fdb6a473e465b960f55e7c" }
|
rocket_cors = { optional = true, git = "https://github.com/lawliet89/rocket_cors", rev = "c17e8145baa4790319fdb6a473e465b960f55e7c" }
|
||||||
|
|
||||||
# rAuth
|
# rAuth
|
||||||
rauth = { git = "https://github.com/insertish/rauth", tag = "1.0.3", features = [ "async-std-runtime" ] }
|
rauth = { git = "https://github.com/insertish/rauth", tag = "1.0.4", features = [ "async-std-runtime" ] }
|
||||||
|
|
||||||
# Sentry
|
# Sentry
|
||||||
sentry = "0.25.0"
|
sentry = "0.25.0"
|
||||||
|
|||||||
Reference in New Issue
Block a user