feat: add friends!
This commit is contained in:
parent
ac3e7e242b
commit
e8b8b49643
13 changed files with 439 additions and 39 deletions
29
src/api/v1/me/friends/uuid.rs
Normal file
29
src/api/v1/me/friends/uuid.rs
Normal file
|
@ -0,0 +1,29 @@
|
|||
use actix_web::{HttpRequest, HttpResponse, delete, web};
|
||||
use uuid::Uuid;
|
||||
|
||||
use crate::{
|
||||
Data,
|
||||
api::v1::auth::check_access_token,
|
||||
error::Error,
|
||||
objects::Me,
|
||||
utils::{get_auth_header, global_checks},
|
||||
};
|
||||
|
||||
#[delete("/friends/{uuid}")]
|
||||
pub async fn delete(req: HttpRequest, path: web::Path<(Uuid,)>, data: web::Data<Data>) -> Result<HttpResponse, Error> {
|
||||
let headers = req.headers();
|
||||
|
||||
let auth_header = get_auth_header(headers)?;
|
||||
|
||||
let mut conn = data.pool.get().await?;
|
||||
|
||||
let uuid = check_access_token(auth_header, &mut conn).await?;
|
||||
|
||||
global_checks(&data, uuid).await?;
|
||||
|
||||
let me = Me::get(&mut conn, uuid).await?;
|
||||
|
||||
me.remove_friend(&mut conn, path.0).await?;
|
||||
|
||||
Ok(HttpResponse::Ok().finish())
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue