1
0
mirror of https://gitlab.com/comunic/comunicapiv3 synced 2024-12-27 22:18:51 +00:00

Can delete all the likes of a user

This commit is contained in:
Pierre HUBERT 2021-01-21 18:26:18 +01:00
parent 7aa0858642
commit b8e9a4c95d
2 changed files with 10 additions and 0 deletions

View File

@ -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(())

View File

@ -89,6 +89,13 @@ pub fn export_all_user(user_id: &UserID) -> ResultBoxError<Vec<UserLike>> {
.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<UserLike> {
Ok(UserLike {