diff --git a/lib/notifier/index.js b/lib/notifier/index.js index 06163030..8bad9a51 100644 --- a/lib/notifier/index.js +++ b/lib/notifier/index.js @@ -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}`)) diff --git a/lib/notifier/notificationCenter.js b/lib/notifier/notificationCenter.js index 11392248..06f6e0ca 100644 --- a/lib/notifier/notificationCenter.js +++ b/lib/notifier/notificationCenter.js @@ -31,7 +31,7 @@ const clearOldCustomerSuspendedNotifications = (customerId, deviceId) => { return queries.invalidateNotification(detailB, 'compliance') } -const customerComplianceNotify = (customer, deviceId, code, days = null) => { +const customerComplianceNotify = (customer, deviceId, code, machineName, days = null) => { // code for now can be "BLOCKED", "SUSPENDED" const detailB = utils.buildDetail({ customerId: customer.id, code, deviceId }) const date = new Date() @@ -40,7 +40,7 @@ const customerComplianceNotify = (customer, deviceId, code, days = null) => { } const message = code === 'SUSPENDED' ? `Customer ${customer.phone} suspended until ${date.toLocaleString()}` : code === 'BLOCKED' ? `Customer ${customer.phone} blocked` : - `Customer ${customer.phone} has pending compliance` + `Customer ${customer.phone} has pending compliance in machine ${machineName}` return clearOldCustomerSuspendedNotifications(customer.id, deviceId) .then(() => queries.getValidNotifications(COMPLIANCE, detailB))