backend/src/api/v1/me/friends/uuid.rs
Radical a602c2624f
All checks were successful
ci/woodpecker/push/build-and-publish Pipeline was successful
style: cargo fmt & clippy fixes
2025-07-20 16:30:46 +02:00

29 lines
678 B
Rust

use std::sync::Arc;
use axum::{
Extension,
extract::{Path, State},
http::StatusCode,
response::IntoResponse,
};
use uuid::Uuid;
use crate::{
AppState, api::v1::auth::CurrentUser, error::Error, objects::Me, utils::global_checks,
};
pub async fn delete(
State(app_state): State<Arc<AppState>>,
Path(friend_uuid): Path<Uuid>,
Extension(CurrentUser(uuid)): Extension<CurrentUser<Uuid>>,
) -> Result<impl IntoResponse, Error> {
global_checks(&app_state, uuid).await?;
let mut conn = app_state.pool.get().await?;
let me = Me::get(&mut conn, uuid).await?;
me.remove_friend(&mut conn, friend_uuid).await?;
Ok(StatusCode::OK)
}