From 472f44b5a57ac7bcf1092fd3b5b88b7d7016c191 Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Thu, 21 Jan 2021 19:06:49 +0100 Subject: [PATCH] Can delete all the custom emojies of a given user --- src/helpers/account_helper.rs | 5 ++++- src/helpers/custom_emojies_helper.rs | 9 +++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/helpers/account_helper.rs b/src/helpers/account_helper.rs index 1fe4031..e6db4b6 100644 --- a/src/helpers/account_helper.rs +++ b/src/helpers/account_helper.rs @@ -9,7 +9,7 @@ use crate::data::new_account::NewAccount; use crate::data::security_settings::SecuritySettings; use crate::data::user::{AccountImageVisibility, UserID, UserPageStatus}; use crate::data::user_token::UserAccessToken; -use crate::helpers::{comments_helper, conversations_helper, database, friends_helper, groups_helper, likes_helper, movies_helper, notifications_helper, posts_helper, survey_helper, user_helper}; +use crate::helpers::{comments_helper, conversations_helper, custom_emojies_helper, database, friends_helper, groups_helper, likes_helper, movies_helper, notifications_helper, posts_helper, survey_helper, user_helper}; use crate::helpers::database::{DeleteQuery, InsertQuery, QueryInfo}; use crate::helpers::likes_helper::LikeType; use crate::utils::crypt_utils::{crypt_pass, rand_str}; @@ -340,6 +340,9 @@ pub fn delete(user_id: &UserID) -> ResultBoxError { // Delete all the likes on the user page likes_helper::delete_all(user_id.id(), LikeType::USER)?; + // Delete all custom user emojies + custom_emojies_helper::delete_all_user(user_id)?; + // TODO : continue work here Ok(()) diff --git a/src/helpers/custom_emojies_helper.rs b/src/helpers/custom_emojies_helper.rs index 3dc4dae..03969cc 100644 --- a/src/helpers/custom_emojies_helper.rs +++ b/src/helpers/custom_emojies_helper.rs @@ -54,6 +54,15 @@ pub fn delete(c: &CustomEmoji) -> ResultBoxError { .exec() } +/// Delete all the custom emojies of a user +pub fn delete_all_user(user_id: &UserID) -> ResultBoxError { + for emoji in &get_list_user(user_id)? { + delete(emoji)?; + } + + Ok(()) +} + /// Turn a database entry into a [CustomEmoji] fn db_to_custom_emoji(row: &database::RowResult) -> ResultBoxError { Ok(CustomEmoji {