From a78510d426c7d44c21466952b86d0e7b2dd6241b Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Tue, 31 Dec 2019 10:26:19 +0100 Subject: [PATCH] Can check following status of a friend --- src/helpers/FriendsHelper.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/helpers/FriendsHelper.ts b/src/helpers/FriendsHelper.ts index b29eff7..32a4ff5 100644 --- a/src/helpers/FriendsHelper.ts +++ b/src/helpers/FriendsHelper.ts @@ -128,6 +128,24 @@ export class FriendsHelper { }) > 0; } + /** + * Check whether a user is following a friend or not + * + * @param userID The ID of the user supposed to following a friend + * @param friendID The target friend + */ + public static async IsFollowing(userID: number, friendID: number) : Promise { + return await DatabaseHelper.Count({ + table: FRIENDS_TABLE, + where: { + ID_personne: userID, + ID_amis: friendID, + actif: 1, + abonnement: 1 + } + }) > 0; + } + /** * Check out whether friendship allows to create posts or not *