From 3597d558f65a6ca76b1e45f00fc8a6395af45281 Mon Sep 17 00:00:00 2001 From: Jose Semedo <jose.semedo@cern.ch> Date: Mon, 21 Mar 2022 14:23:27 +0100 Subject: [PATCH] [HOTFIX] Fixed sendNotification canSendByForm bug --- src/models/channel.ts | 2 +- src/services/impl/notifications/send-notification.ts | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/models/channel.ts b/src/models/channel.ts index e8874fa6..23ea87b2 100644 --- a/src/models/channel.ts +++ b/src/models/channel.ts @@ -326,7 +326,7 @@ export class Channel extends ApiKeyObject { // Checks if user has authorization to send Notification to the channel // via Form/API - async canSendByForm(authorizationBag: AuthorizationBag, targetedNotification = false) { + async canSendByForm(authorizationBag: AuthorizationBag, targetedNotification = false): Promise<boolean> { // No permission to send by Form set if (!this.submissionByForm) return false; diff --git a/src/services/impl/notifications/send-notification.ts b/src/services/impl/notifications/send-notification.ts index 8cf25e6e..a2ccbaff 100644 --- a/src/services/impl/notifications/send-notification.ts +++ b/src/services/impl/notifications/send-notification.ts @@ -37,9 +37,9 @@ export class SendNotification implements Command { if ( !(await targetChannel.canSendByForm( this.authorizationBag, - this.notification.targetUsers !== undefined || - this.notification.targetGroups !== undefined || - this.notification.targetData !== undefined, + Boolean(this.notification.targetUsers) || + Boolean(this.notification.targetGroups) || + Boolean(this.notification.targetData), )) ) throw new ForbiddenError('Sending to Channel not Authorized !'); -- GitLab