Fetch profile route, push badges and status.
This commit is contained in:
@@ -32,11 +32,11 @@ pub async fn req(user: User, target: Ref, message: Json<Data>) -> Result<JsonVal
|
||||
}
|
||||
|
||||
let target = target.fetch_channel().await?;
|
||||
|
||||
let perm = permissions::PermissionCalculator::new(&user)
|
||||
.with_channel(&target)
|
||||
.for_channel()
|
||||
.await?;
|
||||
|
||||
if !perm.get_send_message() {
|
||||
Err(Error::MissingPermission)?
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ use rocket_contrib::json::JsonValue;
|
||||
#[get("/")]
|
||||
pub async fn root() -> JsonValue {
|
||||
json!({
|
||||
"revolt": "0.4.0-alpha.2",
|
||||
"revolt": "0.4.0-alpha.3",
|
||||
"features": {
|
||||
"registration": !*DISABLE_REGISTRATION,
|
||||
"captcha": {
|
||||
|
||||
24
src/routes/users/fetch_profile.rs
Normal file
24
src/routes/users/fetch_profile.rs
Normal 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!({}))
|
||||
}
|
||||
}
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user