mirror of
https://gitlab.com/comunic/comunicapiv3
synced 2024-12-25 13:08:50 +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
|
||||
@ -27,4 +28,11 @@ pub fn save_report(r: Report) -> Res<ReportID> {
|
||||
.add_opt_str("comment", r.comment.as_ref())
|
||||
.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