From 36ecabb729d0910f67e39b7c439e23a102eb2413 Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Wed, 21 Apr 2021 16:41:28 +0200 Subject: [PATCH] Delete all Forez presence when user delete its account --- src/helpers/account_helper.rs | 5 ++++- src/helpers/forez_presence_helper.rs | 7 +++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/helpers/account_helper.rs b/src/helpers/account_helper.rs index fbc1b69..fdf7b2b 100644 --- a/src/helpers/account_helper.rs +++ b/src/helpers/account_helper.rs @@ -14,7 +14,7 @@ use crate::data::new_notifications_settings::NewNotificationsSettings; use crate::data::security_settings::SecuritySettings; use crate::data::user::{AccountImageVisibility, User, UserID, UserPageStatus}; use crate::data::user_token::{PushNotificationToken, UserAccessToken}; -use crate::helpers::{comments_helper, conversations_helper, custom_emojies_helper, database, events_helper, friends_helper, groups_helper, likes_helper, notifications_helper, posts_helper, push_notifications_helper, survey_helper, user_helper}; +use crate::helpers::{comments_helper, conversations_helper, custom_emojies_helper, database, events_helper, forez_presence_helper, friends_helper, groups_helper, likes_helper, notifications_helper, posts_helper, push_notifications_helper, survey_helper, user_helper}; use crate::helpers::database::{DeleteQuery, InsertQuery, QueryInfo, RowResult, UpdateInfo}; use crate::helpers::events_helper::Event; use crate::helpers::likes_helper::LikeType; @@ -397,6 +397,9 @@ pub fn delete(user_id: &UserID) -> ResultBoxError { // Delete all custom user emojies custom_emojies_helper::delete_all_user(user_id)?; + // Delete all forez presences + forez_presence_helper::delete_all_user(user_id)?; + // Delete connections to all services destroy_all_user_tokens(user_id)?; diff --git a/src/helpers/forez_presence_helper.rs b/src/helpers/forez_presence_helper.rs index a33d58d..f89a221 100644 --- a/src/helpers/forez_presence_helper.rs +++ b/src/helpers/forez_presence_helper.rs @@ -24,6 +24,13 @@ pub fn get_user_presences(group_id: &GroupID, user_id: &UserID) -> Res Res { + database::DeleteQuery::new(FOREZ_PRESENCE_TABLE) + .cond_user_id("user_id", user_id) + .exec() +} + /// Update the presences of a user pub fn update(group_id: &GroupID, user_id: &UserID, list: Vec) -> Res { let previous_presences = get_user_presences(group_id, user_id)?;