fix: readd the notification sending function

This commit is contained in:
Sérgio Salgado 2022-02-10 17:03:42 +00:00
parent 4015e23d34
commit 80d7d7184e
2 changed files with 12 additions and 18 deletions

View file

@ -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) {

View file

@ -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)
})
}