fix: readd the notification sending function
This commit is contained in:
parent
4015e23d34
commit
80d7d7184e
2 changed files with 12 additions and 18 deletions
|
|
@ -2,6 +2,7 @@ const express = require('express')
|
||||||
const router = express.Router()
|
const router = express.Router()
|
||||||
|
|
||||||
const cashbox = require('../cashbox-batches')
|
const cashbox = require('../cashbox-batches')
|
||||||
|
const notifier = require('../notifier')
|
||||||
const { getMachine, setMachine } = require('../machine-loader')
|
const { getMachine, setMachine } = require('../machine-loader')
|
||||||
const { loadLatestConfig } = require('../new-settings-loader')
|
const { loadLatestConfig } = require('../new-settings-loader')
|
||||||
const { getCashInSettings } = require('../new-config-manager')
|
const { getCashInSettings } = require('../new-config-manager')
|
||||||
|
|
@ -9,7 +10,9 @@ const { AUTOMATIC } = require('../constants.js')
|
||||||
|
|
||||||
function notifyCashboxRemoval (req, res, next) {
|
function notifyCashboxRemoval (req, res, next) {
|
||||||
const operatorId = res.locals.operatorId
|
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]) => {
|
.then(([machine, config]) => {
|
||||||
const cashInSettings = getCashInSettings(config)
|
const cashInSettings = getCashInSettings(config)
|
||||||
if (cashInSettings.cashboxReset !== AUTOMATIC) {
|
if (cashInSettings.cashboxReset !== AUTOMATIC) {
|
||||||
|
|
|
||||||
|
|
@ -6,24 +6,15 @@ exports.up = function (next) {
|
||||||
`ALTER TYPE notification_type ADD VALUE 'security'`
|
`ALTER TYPE notification_type ADD VALUE 'security'`
|
||||||
]
|
]
|
||||||
|
|
||||||
return loadLatest()
|
const newConfig = {}
|
||||||
.then(config => {
|
newConfig.notifications_email_security = true
|
||||||
const newConfig = {}
|
newConfig.notifications_sms_security = true
|
||||||
if(config.notifications_email_active) {
|
newConfig.notifications_notificationCenter_security = true
|
||||||
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
|
|
||||||
}
|
|
||||||
|
|
||||||
return migrationSaveConfig(newConfig)
|
return migrationSaveConfig(newConfig)
|
||||||
.then(() => db.multi(sql, next))
|
.then(() => db.multi(sql, next))
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
return next(err)
|
return next(err)
|
||||||
})
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue