From 50a16c0f8cc1cfafe24c79cbd070a4485952fee2 Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Fri, 27 Mar 2020 14:24:53 +0100 Subject: [PATCH] Can remove user from all its conversations --- 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 31ae03c..e3c588a 100644 --- a/src/helpers/AccountHelper.ts +++ b/src/helpers/AccountHelper.ts @@ -462,8 +462,11 @@ export class AccountHelper { // Delete conversation messages await ConversationsHelper.DeleteAllUserMessages(userID); + + // Remove the user from all its conversations + await ConversationsHelper.DeleteAllUserConversations(userID); */ - + // TODO : continue work } diff --git a/src/helpers/ConversationsHelper.ts b/src/helpers/ConversationsHelper.ts index 0f1c157..5eaea03 100644 --- a/src/helpers/ConversationsHelper.ts +++ b/src/helpers/ConversationsHelper.ts @@ -390,6 +390,16 @@ export class ConversationsHelper { await this.DeleteMessage(msg); } + /** + * Remove the user from all the conversations he belongs to + * + * @param userID Target user ID + */ + public static async DeleteAllUserConversations(userID: number) { + for(const conv of await this.GetListUser(userID)) + await this.RemoveUserFromConversation(userID, conv.id); + } + /** * Mark the user has seen the last messages of the conversation *