fix: add machine name and timestamp to pending notifs messages
This commit is contained in:
parent
2c8ab635a7
commit
e7f37a4b5b
2 changed files with 7 additions and 6 deletions
|
|
@ -167,6 +167,7 @@ function transactionNotify (tx, rec) {
|
|||
}
|
||||
|
||||
function complianceNotify (settings, customer, deviceId, action, period) {
|
||||
const timestamp = (new Date()).toLocaleString()
|
||||
return queries.getMachineName(deviceId)
|
||||
.then(machineName => {
|
||||
const notifications = configManager.getGlobalNotifications(settings.config)
|
||||
|
|
@ -179,15 +180,15 @@ function complianceNotify (settings, customer, deviceId, action, period) {
|
|||
|
||||
const rec = {
|
||||
sms: {
|
||||
body: `Customer ${customer.phone} ${msgCore[action]} - ${machineName}`
|
||||
body: `Customer ${customer.phone} ${msgCore[action]} - ${machineName}. ${timestamp}`
|
||||
},
|
||||
email: {
|
||||
subject: `Customer compliance`,
|
||||
body: `Customer ${customer.phone} ${msgCore[action]} in machine ${machineName}`
|
||||
body: `Customer ${customer.phone} ${msgCore[action]} in machine ${machineName}. ${timestamp}`
|
||||
},
|
||||
webhook: {
|
||||
topic: `Customer compliance`,
|
||||
content: `Customer ${customer.phone} ${msgCore[action]} in machine ${machineName}`
|
||||
content: `Customer ${customer.phone} ${msgCore[action]} in machine ${machineName}. ${timestamp}`
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -207,7 +208,7 @@ function complianceNotify (settings, customer, deviceId, action, period) {
|
|||
if (smsActive) promises.push(smsFuncs.sendMessage(settings, rec))
|
||||
if (webhookActive) promises.push(webhookFuncs.sendMessage(settings, rec))
|
||||
|
||||
notifyIfActive('compliance', 'customerComplianceNotify', customer, deviceId, action, period)
|
||||
notifyIfActive('compliance', 'customerComplianceNotify', customer, deviceId, action, machineName, period)
|
||||
|
||||
return Promise.all(promises)
|
||||
.catch(err => console.error(`An error occurred when sending a notification. Please check your notification preferences and 3rd party account configuration: ${err.stack}`))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue