diff --git a/src/helpers/account_helper.rs b/src/helpers/account_helper.rs index 6c456f3..f99c200 100644 --- a/src/helpers/account_helper.rs +++ b/src/helpers/account_helper.rs @@ -309,6 +309,9 @@ pub fn delete(user_id: &UserID) -> ResultBoxError { // Delete all user comments comments_helper::delete_all_user(user_id)?; + // Delete all user posts + posts_helper::delete_all_user(user_id)?; + // TODO : continue work here Ok(()) diff --git a/src/helpers/posts_helper.rs b/src/helpers/posts_helper.rs index 0719de0..9557fc2 100644 --- a/src/helpers/posts_helper.rs +++ b/src/helpers/posts_helper.rs @@ -466,6 +466,15 @@ pub fn delete_all_group(group_id: &GroupID) -> ResultBoxError { Ok(()) } +/// Delete all the posts of a given user +pub fn delete_all_user(user_id: &UserID) -> ResultBoxError { + for post in &export_all_posts_user(user_id)? { + delete(&post)?; + } + + Ok(()) +} + /// Get all the posts that use of movie pub fn get_posts_for_movie(m: &Movie) -> ResultBoxError> { database::QueryInfo::new(POSTS_TABLE)