mirror of
https://gitlab.com/comunic/comunicapiv3
synced 2024-11-26 15:29:21 +00:00
Start to delete user account
This commit is contained in:
parent
e26d40183e
commit
f325ec7ae7
@ -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
|
||||
|
||||
|
@ -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> {
|
||||
|
Loading…
Reference in New Issue
Block a user