From 857d56bb0bf046cf68c757d32417153c17449562 Mon Sep 17 00:00:00 2001 From: Denis Bykhov Date: Fri, 19 Apr 2024 21:41:26 +0500 Subject: [PATCH] Use queryFind in isAllowed function in notification trigger (#5409) Signed-off-by: Denis Bykhov --- server-plugins/notification-resources/src/utils.ts | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/server-plugins/notification-resources/src/utils.ts b/server-plugins/notification-resources/src/utils.ts index 41252db4ee..508392577e 100644 --- a/server-plugins/notification-resources/src/utils.ts +++ b/server-plugins/notification-resources/src/utils.ts @@ -140,17 +140,8 @@ export async function isAllowed ( typeId: Ref, providerId: Ref ): Promise { - const setting = ( - await control.findAll( - notification.class.NotificationSetting, - { - attachedTo: providerId, - type: typeId, - modifiedBy: receiver - }, - { limit: 1 } - ) - )[0] + const settings = await control.queryFind(notification.class.NotificationSetting, {}) + const setting = settings.find((p) => p.attachedTo === providerId && p.type === typeId && p.modifiedBy === receiver) if (setting !== undefined) { return setting.enabled }