feat: implement channel invites, perms, group create, members fetch

chore: when you accidentally run fmt
This commit is contained in:
Paul Makles
2022-02-04 21:50:30 +00:00
parent b58755dbeb
commit 88f811761b
59 changed files with 536 additions and 195 deletions

View File

@@ -1,9 +1,12 @@
//! Fetch another user's profile
//!
//!
//! Will fail if the authenticated user does not
//! have permission to access the other user's profile.
use revolt_quark::{Ref, Result, Error, models::{User, user::UserProfile}, perms, Database};
use revolt_quark::{
models::{user::UserProfile, User},
perms, Database, Error, Ref, Result,
};
use rocket::{serde::json::Json, State};
@@ -11,7 +14,12 @@ use rocket::{serde::json::Json, State};
pub async fn req(db: &State<Database>, user: User, target: Ref) -> Result<Json<UserProfile>> {
let target = target.as_user(db).await?;
if perms(&user).user(&target).calc_user(db).await.get_view_profile() {
if perms(&user)
.user(&target)
.calc_user(db)
.await
.get_view_profile()
{
Ok(Json(target.profile.unwrap_or_default()))
} else {
Err(Error::NotFound)