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 {