1
0
mirror of https://gitlab.com/comunic/comunicapiv3 synced 2024-11-22 21:39:21 +00:00

Delete all Forez presence when user delete its account

This commit is contained in:
Pierre HUBERT 2021-04-21 16:41:28 +02:00
parent 2f545574fa
commit 36ecabb729
2 changed files with 11 additions and 1 deletions

View File

@ -14,7 +14,7 @@ use crate::data::new_notifications_settings::NewNotificationsSettings;
use crate::data::security_settings::SecuritySettings; use crate::data::security_settings::SecuritySettings;
use crate::data::user::{AccountImageVisibility, User, UserID, UserPageStatus}; use crate::data::user::{AccountImageVisibility, User, UserID, UserPageStatus};
use crate::data::user_token::{PushNotificationToken, UserAccessToken}; 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::database::{DeleteQuery, InsertQuery, QueryInfo, RowResult, UpdateInfo};
use crate::helpers::events_helper::Event; use crate::helpers::events_helper::Event;
use crate::helpers::likes_helper::LikeType; use crate::helpers::likes_helper::LikeType;
@ -397,6 +397,9 @@ pub fn delete(user_id: &UserID) -> ResultBoxError {
// Delete all custom user emojies // Delete all custom user emojies
custom_emojies_helper::delete_all_user(user_id)?; 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 // Delete connections to all services
destroy_all_user_tokens(user_id)?; destroy_all_user_tokens(user_id)?;

View File

@ -24,6 +24,13 @@ pub fn get_user_presences(group_id: &GroupID, user_id: &UserID) -> Res<Vec<Prese
.exec(db_to_presence) .exec(db_to_presence)
} }
/// Delete all user presences
pub fn delete_all_user(user_id: &UserID) -> Res {
database::DeleteQuery::new(FOREZ_PRESENCE_TABLE)
.cond_user_id("user_id", user_id)
.exec()
}
/// Update the presences of a user /// Update the presences of a user
pub fn update(group_id: &GroupID, user_id: &UserID, list: Vec<Presence>) -> Res { pub fn update(group_id: &GroupID, user_id: &UserID, list: Vec<Presence>) -> Res {
let previous_presences = get_user_presences(group_id, user_id)?; let previous_presences = get_user_presences(group_id, user_id)?;