forked from jmug/stoatchat
feat(users): implement relationships, DMs, proper perms
This commit is contained in:
@@ -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))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user