fix: add machine name and timestamp to pending notifs messages

This commit is contained in:
siiky 2024-06-28 16:24:36 +01:00
parent 2c8ab635a7
commit e7f37a4b5b
2 changed files with 7 additions and 6 deletions

View file

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