27 lines
643 B
Rust
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)
|
|
}
|