fix: short-circuit fetch user route if self
This commit is contained in:
@@ -8,6 +8,10 @@ use rocket::{serde::json::Json, State};
|
||||
#[openapi(tag = "User Information")]
|
||||
#[get("/<target>")]
|
||||
pub async fn req(db: &State<Database>, user: User, target: Ref) -> Result<Json<User>> {
|
||||
if target.id == user.id {
|
||||
return Ok(Json(user));
|
||||
}
|
||||
|
||||
let target = target.as_user(db).await?;
|
||||
|
||||
let permissions = perms(&user).user(&target).calc_user(db).await;
|
||||
|
||||
@@ -20,12 +20,12 @@ pub struct MutualResponse {
|
||||
#[openapi(tag = "Relationships")]
|
||||
#[get("/<target>/mutual")]
|
||||
pub async fn req(db: &State<Database>, user: User, target: Ref) -> Result<Json<MutualResponse>> {
|
||||
let target = target.as_user(db).await?;
|
||||
|
||||
if target.id == user.id {
|
||||
return Err(Error::InvalidOperation);
|
||||
}
|
||||
|
||||
let target = target.as_user(db).await?;
|
||||
|
||||
if perms(&user)
|
||||
.user(&target)
|
||||
.calc_user(db)
|
||||
|
||||
Reference in New Issue
Block a user