From 30740b801689642daa62d133589f948d142fbbe6 Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Fri, 27 Mar 2020 14:41:18 +0100 Subject: [PATCH] Delete all user friends --- src/helpers/AccountHelper.ts | 3 +++ src/helpers/FriendsHelper.ts | 15 +++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/src/helpers/AccountHelper.ts b/src/helpers/AccountHelper.ts index 23fc5d0..f9e5d36 100644 --- a/src/helpers/AccountHelper.ts +++ b/src/helpers/AccountHelper.ts @@ -469,6 +469,9 @@ export class AccountHelper { // Delete all the notifications related with the user await NotificationsHelper.DeleteAllRelatedWithUser(userID); + + // Delete all user friends, including friendship requests + await FriendsHelper.DeleteAllUser(userID); */ // TODO : continue work diff --git a/src/helpers/FriendsHelper.ts b/src/helpers/FriendsHelper.ts index 046bf75..3631d59 100644 --- a/src/helpers/FriendsHelper.ts +++ b/src/helpers/FriendsHelper.ts @@ -329,6 +329,21 @@ export class FriendsHelper { return result["autoriser_post_page"] == 1; } + /** + * Delete all the friends of a given user + * + * @param userID Target user ID + */ + public static async DeleteAllUser(userID: number) { + await DatabaseHelper.DeleteRows(FRIENDS_TABLE, { + ID_personne: userID + }) + + await DatabaseHelper.DeleteRows(FRIENDS_TABLE, { + ID_amis: userID + }) + } + /** * Turn a database entry into a {Friend} object *