This repository has been archived on 2024-08-23. You can view files and clone it, but cannot push or open issues or pull requests.
2024-07-28 09:37:39 +03:00

27 lines
643 B
Rust

use crate::prelude::*;
#[derive(Deserialize, Debug)]
pub struct Params {
folder_id: Uuid,
user_id: i32,
}
pub async fn delete(
claims: Claims,
State(state): State<AppState>,
Json(params): Json<Params>,
) -> Result<StatusCode, StatusCode> {
if params.user_id != claims.user_id {
db::folder::get_permissions(params.folder_id, claims.user_id, &state.pool)
.await
.handle_internal()?
.can_manage_guard()?;
}
db::permissions::delete_for_folder(params.folder_id, params.user_id, &state.pool)
.await
.handle_internal()?;
Ok(StatusCode::NO_CONTENT)
}