Can leave a family

This commit is contained in:
2023-06-21 17:35:07 +02:00
parent ad54f83c2c
commit a94b26b23c
5 changed files with 60 additions and 8 deletions

View File

@ -79,6 +79,13 @@ pub async fn single_info(f: FamilyInPath) -> HttpResult {
.json(families_service::get_family_membership(f.family_id(), f.user_id()).await?))
}
/// Attempt to leave a family
pub async fn leave(f: FamilyInPath) -> HttpResult {
families_service::remove_membership(f.family_id(), f.user_id()).await?;
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?))