1
0
mirror of https://gitlab.com/comunic/comunicapiv3 synced 2024-12-27 22:18:51 +00:00

Start to delete user account

This commit is contained in:
Pierre HUBERT 2021-01-21 18:05:48 +01:00
parent e26d40183e
commit f325ec7ae7
2 changed files with 16 additions and 2 deletions

View File

@ -300,10 +300,11 @@ pub fn export(user_id: &UserID) -> ResultBoxError<AccountExport> {
}
/// Delete a user's account
pub fn delete(_user_id: &UserID) -> ResultBoxError {
pub fn delete(user_id: &UserID) -> ResultBoxError {
// TODO : close all websockets of user
// TODO : Delete all group membership
// Delete all group membership
groups_helper::delete_all_user_groups(user_id)?;
// TODO : continue work here

View File

@ -488,6 +488,19 @@ pub fn delete(group_id: &GroupID) -> ResultBoxError {
.exec()
}
/// Delete all the groups a user belongs to
pub fn delete_all_user_groups(user_id: &UserID) -> ResultBoxError {
for group_id in &get_list_user(user_id, false)? {
if is_last_admin(group_id, user_id)? {
delete(group_id)?;
} else {
delete_member(group_id, user_id)?;
}
}
Ok(())
}
/// Turn a database entry into a group struct
fn db_to_group(row: &database::RowResult) -> ResultBoxError<Group> {