1
0
mirror of https://gitlab.com/comunic/comunicapiv3 synced 2024-11-26 07:19:22 +00:00

Delete all forez presence of a group when deleting a group

This commit is contained in:
Pierre HUBERT 2021-04-21 18:43:32 +02:00
parent 36ecabb729
commit c177c2c2f6
2 changed files with 11 additions and 1 deletions

View File

@ -31,6 +31,13 @@ pub fn delete_all_user(user_id: &UserID) -> Res {
.exec() .exec()
} }
/// Delete all the presences of a given group
pub fn delete_all_group(group_id: &GroupID) -> Res {
database::DeleteQuery::new(FOREZ_PRESENCE_TABLE)
.cond_group_id("group_id", group_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)?;

View File

@ -9,7 +9,7 @@ use crate::data::group_id::GroupID;
use crate::data::group_member::{GroupMember, GroupMembershipLevel}; use crate::data::group_member::{GroupMember, GroupMembershipLevel};
use crate::data::new_group::NewGroup; use crate::data::new_group::NewGroup;
use crate::data::user::UserID; use crate::data::user::UserID;
use crate::helpers::{conversations_helper, database, likes_helper, notifications_helper, posts_helper}; use crate::helpers::{conversations_helper, database, forez_presence_helper, likes_helper, notifications_helper, posts_helper};
use crate::helpers::likes_helper::LikeType; use crate::helpers::likes_helper::LikeType;
use crate::utils::date_utils::time; use crate::utils::date_utils::time;
@ -505,6 +505,9 @@ pub fn delete(group_id: &GroupID) -> ResultBoxError {
// Delete all conversations related with the group // Delete all conversations related with the group
conversations_helper::delete_all_group_conversations(group_id)?; conversations_helper::delete_all_group_conversations(group_id)?;
// Delete all Forez presences related with the group
forez_presence_helper::delete_all_group(group_id)?;
// Delete all group members // Delete all group members
database::DeleteQuery::new(GROUPS_MEMBERS_TABLE) database::DeleteQuery::new(GROUPS_MEMBERS_TABLE)
.cond_group_id("groups_id", group_id) .cond_group_id("groups_id", group_id)