From 5a7e3562659a8d425bdedd12f54e5dda08a10d5e Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Thu, 21 Jan 2021 18:13:01 +0100 Subject: [PATCH] Delete all comments of user --- src/helpers/account_helper.rs | 3 +++ src/helpers/comments_helper.rs | 9 +++++++++ 2 files changed, 12 insertions(+) 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