Add DELETE /family/{id} route
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
use crate::constants::StaticConstraints;
|
||||
use crate::controllers::HttpResult;
|
||||
use crate::extractors::family_extractor::FamilyInPath;
|
||||
use crate::extractors::family_extractor::{FamilyInPath, FamilyInPathWithAdminMembership};
|
||||
use crate::services::login_token_service::LoginToken;
|
||||
use crate::services::rate_limiter_service::RatedAction;
|
||||
use crate::services::{families_service, rate_limiter_service};
|
||||
@ -86,6 +86,14 @@ pub async fn leave(f: FamilyInPath) -> HttpResult {
|
||||
Ok(HttpResponse::Accepted().finish())
|
||||
}
|
||||
|
||||
/// Delete a family
|
||||
pub async fn delete(f: FamilyInPathWithAdminMembership) -> HttpResult {
|
||||
families_service::delete_family(f.family_id()).await?;
|
||||
log::info!("User {:?} deleted family {:?}", f.user_id(), f.family_id());
|
||||
|
||||
Ok(HttpResponse::Accepted().finish())
|
||||
}
|
||||
|
||||
/// Get the list of users who belongs to a family
|
||||
pub async fn users(f: FamilyInPath) -> HttpResult {
|
||||
Ok(HttpResponse::Ok().json(families_service::get_memberships_of_family(f.family_id()).await?))
|
||||
|
Reference in New Issue
Block a user