diff --git a/src/helpers/account_helper.rs b/src/helpers/account_helper.rs index 8011dee..ae11a30 100644 --- a/src/helpers/account_helper.rs +++ b/src/helpers/account_helper.rs @@ -315,6 +315,9 @@ pub fn delete(user_id: &UserID) -> ResultBoxError { // Delete all responses of user to surveys survey_helper::delete_all_user_responses(user_id)?; + // Delete all the likes created by the user + likes_helper::delete_all_user(user_id)?; + // TODO : continue work here Ok(()) diff --git a/src/helpers/likes_helper.rs b/src/helpers/likes_helper.rs index 7ebc855..f73a147 100644 --- a/src/helpers/likes_helper.rs +++ b/src/helpers/likes_helper.rs @@ -89,6 +89,13 @@ pub fn export_all_user(user_id: &UserID) -> ResultBoxError> { .exec(db_to_user_like) } +/// Delete all the likes created by a user +pub fn delete_all_user(user_id: &UserID) -> ResultBoxError { + database::DeleteQuery::new(LIKES_TABLE) + .cond_user_id("ID_personne", user_id) + .exec() +} + /// Turn a database entry into a like entry fn db_to_user_like(r: &database::RowResult) -> ResultBoxError { Ok(UserLike {