feat: create cashbox removal notifications
This commit is contained in:
parent
73bd11b38b
commit
598135ccaf
6 changed files with 92 additions and 4 deletions
|
|
@ -246,6 +246,41 @@ function sendTransactionMessage (rec, isHighValueTx) {
|
|||
})
|
||||
}
|
||||
|
||||
function cashboxNotify (deviceId) {
|
||||
return Promise.all([
|
||||
settingsLoader.loadLatest(),
|
||||
queries.getMachineName(deviceId)
|
||||
])
|
||||
.then(([settings, machineName]) => {
|
||||
const notifications = configManager.getGlobalNotifications(settings.config)
|
||||
const rec = {
|
||||
sms: {
|
||||
body: `Cashbox removed - ${machineName}`
|
||||
},
|
||||
email: {
|
||||
subject: `Cashbox removal`,
|
||||
body: `Cashbox removed in machine ${machineName}`
|
||||
}
|
||||
}
|
||||
|
||||
const promises = []
|
||||
|
||||
const emailActive =
|
||||
notifications.email.active &&
|
||||
notifications.email.security
|
||||
|
||||
const smsActive =
|
||||
notifications.sms.active &&
|
||||
notifications.sms.security
|
||||
|
||||
if (emailActive) promises.push(emailFuncs.sendMessage(settings, rec))
|
||||
if (smsActive) promises.push(smsFuncs.sendMessage(settings, rec))
|
||||
notifyIfActive('security', 'cashboxNotify', deviceId)
|
||||
|
||||
return Promise.all(promises)
|
||||
})
|
||||
}
|
||||
|
||||
// for notification center, check if type of notification is active before calling the respective notify function
|
||||
const notifyIfActive = (type, fnName, ...args) => {
|
||||
return settingsLoader.loadLatest().then(settings => {
|
||||
|
|
@ -263,5 +298,6 @@ module.exports = {
|
|||
checkPings,
|
||||
checkStuckScreen,
|
||||
sendRedemptionMessage,
|
||||
cashboxNotify,
|
||||
notifyIfActive
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue