From 15c2652b21605dc375f731e511c6b2535cf13671 Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Fri, 27 Mar 2020 11:35:54 +0100 Subject: [PATCH] Delete all the comments of the user --- src/helpers/AccountHelper.ts | 8 ++++++-- src/helpers/CommentsHelper.ts | 10 ++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/helpers/AccountHelper.ts b/src/helpers/AccountHelper.ts index a9bdbf2..ae592d5 100644 --- a/src/helpers/AccountHelper.ts +++ b/src/helpers/AccountHelper.ts @@ -442,9 +442,13 @@ export class AccountHelper { */ public static async Delete(userID: number) { - // Delete all groups memberships + /*// Delete all groups memberships await GroupsHelper.DeleteAllUsersGroups(userID); - + + // Delete all user comments + await CommentsHelper.DeleteAllUser(userID); + */ + // TODO : continue work } diff --git a/src/helpers/CommentsHelper.ts b/src/helpers/CommentsHelper.ts index c9a4861..5a5c584 100644 --- a/src/helpers/CommentsHelper.ts +++ b/src/helpers/CommentsHelper.ts @@ -172,6 +172,16 @@ export class CommentsHelper { })).map((row) => this.DbToComment(row)); } + /** + * Delete all the comment of a given user + * + * @param userID Target user id + */ + public static async DeleteAllUser(userID: number) { + for(const el of await this.ExportAllUser(userID)) + await this.Delete(el); + } + /** * Turn a database entry into a Comment object *