1
0
mirror of https://gitlab.com/comunic/comunicapiv3 synced 2024-11-25 23:09:22 +00:00

Delete all the reports from a user on its deletion

This commit is contained in:
Pierre HUBERT 2022-03-17 17:33:38 +01:00
parent 51b413b059
commit 5e6399d94e
2 changed files with 12 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, UserPageVisibility}; use crate::data::user::{AccountImageVisibility, User, UserID, UserPageVisibility};
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, forez_presence_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, reports_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;
@ -405,6 +405,9 @@ pub async 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 the reports of the user
reports_helper::delete_all_from_user(user_id)?;
// Delete all forez presences // Delete all forez presences
forez_presence_helper::delete_all_user(user_id)?; forez_presence_helper::delete_all_user(user_id)?;

View File

@ -1,6 +1,7 @@
use crate::constants::database_tables_names::REPORTS_TABLE; use crate::constants::database_tables_names::REPORTS_TABLE;
use crate::data::error::Res; use crate::data::error::Res;
use crate::data::report::{Report, ReportID}; use crate::data::report::{Report, ReportID};
use crate::data::user::UserID;
use crate::helpers::database; use crate::helpers::database;
/// Check if a report has already been saved by the same user on the same resource /// Check if a report has already been saved by the same user on the same resource
@ -28,3 +29,10 @@ pub fn save_report(r: Report) -> Res<ReportID> {
.insert_expect_result() .insert_expect_result()
.map(|i| ReportID(i)) .map(|i| ReportID(i))
} }
/// Delete all the reports created by a user
pub fn delete_all_from_user(user: &UserID) -> Res {
database::DeleteQuery::new(REPORTS_TABLE)
.cond_user_id("user_id", user)
.exec()
}