feat(users): implement relationships, DMs, proper perms

This commit is contained in:
Paul Makles
2022-02-04 13:38:24 +00:00
parent 63064cc9bb
commit 1aafa51033
11 changed files with 117 additions and 77 deletions

View File

@@ -1,11 +1,13 @@
use revolt_quark::{Error, Result};
use revolt_quark::models::User;
use revolt_quark::{Result, Database};
use futures::try_join;
use mongodb::bson::doc;
use mongodb::options::{Collation, FindOneOptions};
use rocket::serde::json::Value;
use rocket::State;
use rocket::serde::json::Json;
#[put("/<username>/friend")]
pub async fn req(/*user: UserRef,*/ username: String) -> Result<Value> {
todo!()
pub async fn req(db: &State<Database>, user: User, username: String) -> Result<Json<User>> {
let mut target = db.fetch_user_by_username(&username).await?;
user.add_friend(db, &mut target).await?;
Ok(Json(target.with_auto_perspective(db, &user).await))
}