From 01245a1778591bfa4d2a2f3a8aaaeb290ee510a1 Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Fri, 27 Mar 2020 14:14:45 +0100 Subject: [PATCH] Delete all conversation messages of the user --- src/helpers/AccountHelper.ts | 5 ++++- src/helpers/ConversationsHelper.ts | 10 ++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/helpers/AccountHelper.ts b/src/helpers/AccountHelper.ts index 0317a42..31ae03c 100644 --- a/src/helpers/AccountHelper.ts +++ b/src/helpers/AccountHelper.ts @@ -459,8 +459,11 @@ export class AccountHelper { // Delete all user movies await MoviesHelper.DeleteAllUser(userID); - */ + // Delete conversation messages + await ConversationsHelper.DeleteAllUserMessages(userID); + */ + // TODO : continue work } diff --git a/src/helpers/ConversationsHelper.ts b/src/helpers/ConversationsHelper.ts index 58dc28f..0f1c157 100644 --- a/src/helpers/ConversationsHelper.ts +++ b/src/helpers/ConversationsHelper.ts @@ -380,6 +380,16 @@ export class ConversationsHelper { })).map(m => this.DBToConversationMessage(m.conv_id, m)); } + /** + * Delete all the messages of a given user + * + * @param userID Target user ID + */ + public static async DeleteAllUserMessages(userID: number) { + for(const msg of await this.ExportAllMessages(userID)) + await this.DeleteMessage(msg); + } + /** * Mark the user has seen the last messages of the conversation *