fix: add a friend via uesrname instead of their UUID
This commit is contained in:
parent
5f8d0271e7
commit
e17fc9fff0
1 changed files with 4 additions and 8 deletions
|
@ -1,15 +1,10 @@
|
|||
use ::uuid::Uuid;
|
||||
use actix_web::{HttpRequest, HttpResponse, get, post, web};
|
||||
use serde::Deserialize;
|
||||
|
||||
pub mod uuid;
|
||||
|
||||
use crate::{
|
||||
Data,
|
||||
api::v1::auth::check_access_token,
|
||||
error::Error,
|
||||
objects::Me,
|
||||
utils::{get_auth_header, global_checks},
|
||||
api::v1::auth::check_access_token, error::Error, objects::Me, utils::{get_auth_header, global_checks, user_uuid_from_identifier}, Data
|
||||
};
|
||||
|
||||
/// Returns a list of users that are your friends
|
||||
|
@ -34,7 +29,7 @@ pub async fn get(req: HttpRequest, data: web::Data<Data>) -> Result<HttpResponse
|
|||
|
||||
#[derive(Deserialize)]
|
||||
struct UserReq {
|
||||
uuid: Uuid,
|
||||
username: String,
|
||||
}
|
||||
|
||||
/// `POST /api/v1/me/friends` Send friend request
|
||||
|
@ -74,7 +69,8 @@ pub async fn post(
|
|||
|
||||
let me = Me::get(&mut conn, uuid).await?;
|
||||
|
||||
me.add_friend(&mut conn, json.uuid).await?;
|
||||
let target_uuid = user_uuid_from_identifier(&mut conn, &json.username).await?;
|
||||
me.add_friend(&mut conn, target_uuid).await?;
|
||||
|
||||
Ok(HttpResponse::Ok().finish())
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue