From 4cd23d56361dec3c3a79f7db7cda0b6c73721431 Mon Sep 17 00:00:00 2001 From: Andrea Vos Date: Thu, 11 Jan 2024 21:46:37 +0100 Subject: [PATCH] remove duplication of isGranted in notify.js (was blocked by .mjs changes) --- server/notify.js | 22 +--------------------- 1 file changed, 1 insertion(+), 21 deletions(-) diff --git a/server/notify.js b/server/notify.js index 03653110d..4c5a31921 100644 --- a/server/notify.js +++ b/server/notify.js @@ -2,27 +2,7 @@ import '../src/dotenv.js'; import dbConnection from './db.js'; import mailer from '../src/mailer.js'; - -// TODO duplication... -const isGranted = (user, locale, area) => { - if (area === '*') { - return user.roles.split('|').includes('*'); - } - - for (const permission of user.roles.split('|')) { - if (permission === '*') { - return true; - } - const [permissionLocale, permissionArea] = permission.split('-'); - if ((permissionLocale === '*' || permissionLocale === locale || locale === null) && - (permissionArea === '*' && area !== 'code' && area !== 'org' || permissionArea === area || area === '' || area === 'panel') - ) { - return true; - } - } - - return false; -}; +import { isGranted } from '../src/helpers.js'; const shouldNotify = (frequency) => { if (frequency === 0) {