From 80d7d7184e98a89108810bef76a123f8b400ff9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9rgio=20Salgado?= Date: Thu, 10 Feb 2022 17:03:42 +0000 Subject: [PATCH] fix: readd the notification sending function --- lib/routes/cashboxRoutes.js | 5 +++- .../1621430588944-notify-cashbox-removal.js | 25 ++++++------------- 2 files changed, 12 insertions(+), 18 deletions(-) diff --git a/lib/routes/cashboxRoutes.js b/lib/routes/cashboxRoutes.js index 1747187a..34ca1d68 100644 --- a/lib/routes/cashboxRoutes.js +++ b/lib/routes/cashboxRoutes.js @@ -2,6 +2,7 @@ const express = require('express') const router = express.Router() const cashbox = require('../cashbox-batches') +const notifier = require('../notifier') const { getMachine, setMachine } = require('../machine-loader') const { loadLatestConfig } = require('../new-settings-loader') const { getCashInSettings } = require('../new-config-manager') @@ -9,7 +10,9 @@ const { AUTOMATIC } = require('../constants.js') function notifyCashboxRemoval (req, res, next) { const operatorId = res.locals.operatorId - return Promise.all([getMachine(req.deviceId), loadLatestConfig()]) + + return notifier.cashboxNotify(req.deviceId) + .then(() => Promise.all([getMachine(req.deviceId), loadLatestConfig()])) .then(([machine, config]) => { const cashInSettings = getCashInSettings(config) if (cashInSettings.cashboxReset !== AUTOMATIC) { diff --git a/migrations/1621430588944-notify-cashbox-removal.js b/migrations/1621430588944-notify-cashbox-removal.js index df540854..c8a7a21b 100644 --- a/migrations/1621430588944-notify-cashbox-removal.js +++ b/migrations/1621430588944-notify-cashbox-removal.js @@ -6,24 +6,15 @@ exports.up = function (next) { `ALTER TYPE notification_type ADD VALUE 'security'` ] - return loadLatest() - .then(config => { - const newConfig = {} - if(config.notifications_email_active) { - newConfig.notifications_email_security = true - } - if(config.notifications_sms_active) { - newConfig.notifications_sms_security = true - } - if(config.notifications_notificationCenter_active) { - newConfig.notifications_notificationCenter_security = true - } + const newConfig = {} + newConfig.notifications_email_security = true + newConfig.notifications_sms_security = true + newConfig.notifications_notificationCenter_security = true - return migrationSaveConfig(newConfig) - .then(() => db.multi(sql, next)) - .catch(err => { - return next(err) - }) + return migrationSaveConfig(newConfig) + .then(() => db.multi(sql, next)) + .catch(err => { + return next(err) }) }