Fetch profile route, push badges and status.

This commit is contained in:
Paul
2021-04-02 21:55:02 +01:00
parent 3797878d20
commit 78c42fd412
8 changed files with 56 additions and 6 deletions

View File

@@ -0,0 +1,24 @@
use crate::database::*;
use crate::util::result::{Error, Result};
use mongodb::bson::doc;
use rocket_contrib::json::JsonValue;
#[get("/<target>/profile")]
pub async fn req(user: User, target: Ref) -> Result<JsonValue> {
let target = target.fetch_user().await?;
let perm = permissions::PermissionCalculator::new(&user)
.with_user(&target)
.for_user_given()
.await?;
if !perm.get_view_profile() {
Err(Error::MissingPermission)?
}
if target.profile.is_some() {
Ok(json!({ "profile": target.profile }))
} else {
Ok(json!({}))
}
}

View File

@@ -3,6 +3,7 @@ use rocket::Route;
mod add_friend;
mod block_user;
mod fetch_dms;
mod fetch_profile;
mod fetch_relationship;
mod fetch_relationships;
mod fetch_user;
@@ -19,6 +20,7 @@ pub fn routes() -> Vec<Route> {
fetch_user::req,
get_default_avatar::req,
get_avatar::req,
fetch_profile::req,
// Direct Messaging
fetch_dms::req,
open_dm::req,