diff --git a/src/helpers/account_helper.rs b/src/helpers/account_helper.rs index dddb56e..6c456f3 100644 --- a/src/helpers/account_helper.rs +++ b/src/helpers/account_helper.rs @@ -306,6 +306,9 @@ pub fn delete(user_id: &UserID) -> ResultBoxError { // Delete all group membership groups_helper::delete_all_user_groups(user_id)?; + // Delete all user comments + comments_helper::delete_all_user(user_id)?; + // TODO : continue work here Ok(()) diff --git a/src/helpers/comments_helper.rs b/src/helpers/comments_helper.rs index 8bf24f6..5f15f6f 100644 --- a/src/helpers/comments_helper.rs +++ b/src/helpers/comments_helper.rs @@ -97,5 +97,14 @@ pub fn delete_all(post_id: u64) -> ResultBoxError { delete(c)?; } + Ok(()) +} + +/// Delete all the comments created by a user +pub fn delete_all_user(user_id: &UserID) -> ResultBoxError { + for comment in &export_all_user(user_id)? { + delete(comment)?; + } + Ok(()) } \ No newline at end of file