mirror of
https://gitlab.com/comunic/comunicapiv3
synced 2024-11-22 13:29:21 +00:00
Delete all the reports from a user on its deletion
This commit is contained in:
parent
51b413b059
commit
5e6399d94e
@ -14,7 +14,7 @@ use crate::data::new_notifications_settings::NewNotificationsSettings;
|
||||
use crate::data::security_settings::SecuritySettings;
|
||||
use crate::data::user::{AccountImageVisibility, User, UserID, UserPageVisibility};
|
||||
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::events_helper::Event;
|
||||
use crate::helpers::likes_helper::LikeType;
|
||||
@ -405,6 +405,9 @@ pub async fn delete(user_id: &UserID) -> ResultBoxError {
|
||||
// Delete all custom user emojies
|
||||
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
|
||||
forez_presence_helper::delete_all_user(user_id)?;
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
use crate::constants::database_tables_names::REPORTS_TABLE;
|
||||
use crate::data::error::Res;
|
||||
use crate::data::report::{Report, ReportID};
|
||||
use crate::data::user::UserID;
|
||||
use crate::helpers::database;
|
||||
|
||||
/// 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()
|
||||
.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()
|
||||
}
|
Loading…
Reference in New Issue
Block a user