From e3dec0ccafb6470feb4f51fb60c671a9e44c2ce3 Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Sat, 30 Nov 2019 14:19:50 +0100 Subject: [PATCH] Can check whether a user is the moderator of a conversation or not --- src/helpers/ConversationsHelper.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/helpers/ConversationsHelper.ts b/src/helpers/ConversationsHelper.ts index 3136e11..5a2c5a7 100644 --- a/src/helpers/ConversationsHelper.ts +++ b/src/helpers/ConversationsHelper.ts @@ -166,6 +166,22 @@ export class ConversationsHelper { }); } + /** + * Check out whether a user is the moderator of a conversation or not + * + * @param userID User to check + * @param convID Target conversation + */ + public static async IsUserModerator(userID : number, convID : number) : Promise { + return await DatabaseHelper.Count({ + table: USERS_TABLE, + where: { + id: convID, + user_id: userID + } + }) == 1; + } + /** * Get the list of members of a conversation *