Repair account deletion
This commit is contained in:
parent
a94b26b23c
commit
2d7bf10fc2
@ -70,7 +70,7 @@ pub async fn is_member(family_id: FamilyID, user_id: UserID) -> anyhow::Result<b
|
||||
.map(|c: i64| c > 0)
|
||||
}
|
||||
|
||||
/// Get the memberships of a user
|
||||
/// Get the memberships of a user, with family info
|
||||
pub async fn get_user_family_memberships(user_id: UserID) -> anyhow::Result<Vec<FamilyMembership>> {
|
||||
db_connection::execute(|conn| {
|
||||
families_memberships::table
|
||||
@ -79,6 +79,15 @@ pub async fn get_user_family_memberships(user_id: UserID) -> anyhow::Result<Vec<
|
||||
})
|
||||
}
|
||||
|
||||
/// Get the memberships of a user, without family info
|
||||
pub async fn get_user_memberships(user_id: UserID) -> anyhow::Result<Vec<Membership>> {
|
||||
db_connection::execute(|conn| {
|
||||
memberships::table
|
||||
.filter(memberships::dsl::user_id.eq(user_id.0))
|
||||
.get_results(conn)
|
||||
})
|
||||
}
|
||||
|
||||
/// Get information about a membership of a user
|
||||
pub async fn get_membership(family_id: FamilyID, user_id: UserID) -> anyhow::Result<Membership> {
|
||||
db_connection::execute(|conn| {
|
||||
@ -178,6 +187,10 @@ pub async fn remove_membership(family_id: FamilyID, user_id: UserID) -> anyhow::
|
||||
}
|
||||
|
||||
/// Remove all memberships of user
|
||||
pub async fn remove_all_user_membership(_user_id: UserID) -> anyhow::Result<()> {
|
||||
todo!()
|
||||
pub async fn remove_all_user_membership(user_id: UserID) -> anyhow::Result<()> {
|
||||
for m in get_user_memberships(user_id).await? {
|
||||
remove_membership(m.family_id(), user_id).await?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user