Use queryFind in isAllowed function in notification trigger (#5409)

Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
Denis Bykhov 2024-04-19 21:41:26 +05:00 committed by GitHub
parent 02cecb3820
commit 857d56bb0b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -140,17 +140,8 @@ export async function isAllowed (
typeId: Ref<BaseNotificationType>, typeId: Ref<BaseNotificationType>,
providerId: Ref<NotificationProvider> providerId: Ref<NotificationProvider>
): Promise<boolean> { ): Promise<boolean> {
const setting = ( const settings = await control.queryFind(notification.class.NotificationSetting, {})
await control.findAll( const setting = settings.find((p) => p.attachedTo === providerId && p.type === typeId && p.modifiedBy === receiver)
notification.class.NotificationSetting,
{
attachedTo: providerId,
type: typeId,
modifiedBy: receiver
},
{ limit: 1 }
)
)[0]
if (setting !== undefined) { if (setting !== undefined) {
return setting.enabled return setting.enabled
} }