update cryptoBalance notification
This commit is contained in:
parent
6759bec826
commit
e8356c1041
8 changed files with 599 additions and 378 deletions
|
|
@ -12,14 +12,18 @@ const STALE_STATE = 2 * T.minute
|
|||
const NETWORK_DOWN_TIME = 1 * T.minute
|
||||
const ALERT_SEND_INTERVAL = T.hour
|
||||
|
||||
const PING = Symbol('PING')
|
||||
const STALE = Symbol('STALE')
|
||||
const LOW_BALANCE = Symbol('LOW_BALANCE')
|
||||
const PING = 'PING'
|
||||
const STALE = 'STALE'
|
||||
const LOW_CRYPTO_BALANCE = 'LOW_CRYPTO_BALANCE'
|
||||
const CASH_BOX_FULL = 'CASH_BOX_FULL'
|
||||
const LOW_CASH_OUT = 'LOW_CASH_OUT'
|
||||
|
||||
const CODES_DISPLAY = {
|
||||
[PING]: 'Machine Down',
|
||||
[STALE]: 'Machine Stuck',
|
||||
[LOW_BALANCE]: 'Low Balance'
|
||||
PING: 'Machine Down',
|
||||
STALE: 'Machine Stuck',
|
||||
LOW_CRYPTO_BALANCE: 'Low Crypto Balance',
|
||||
CASH_BOX_FULL: 'Cash box full',
|
||||
LOW_CASH_OUT: 'Low Cash-out'
|
||||
}
|
||||
|
||||
let alertFingerprint
|
||||
|
|
@ -151,7 +155,7 @@ function checkStatus (plugins) {
|
|||
.then(([balances, events, devices]) => {
|
||||
return checkPings(devices)
|
||||
.then(pings => {
|
||||
alerts.general = balances
|
||||
alerts.general = _.filter(r => !r.deviceId, balances)
|
||||
devices.forEach(function (device) {
|
||||
const deviceId = device.deviceId
|
||||
const deviceName = device.name
|
||||
|
|
@ -159,12 +163,13 @@ function checkStatus (plugins) {
|
|||
return eventRow.device_id === deviceId
|
||||
})
|
||||
|
||||
const balanceAlerts = _.filter(['deviceId', deviceId], balances)
|
||||
const ping = pings[deviceId] || []
|
||||
const stuckScreen = checkStuckScreen(deviceEvents)
|
||||
|
||||
const deviceAlerts = _.isEmpty(ping) ? stuckScreen : ping
|
||||
|
||||
alerts.devices[deviceId] = deviceAlerts
|
||||
alerts.devices[deviceId] = _.concat(deviceAlerts, balanceAlerts)
|
||||
alerts.deviceNames[deviceId] = deviceName
|
||||
})
|
||||
|
||||
|
|
@ -188,9 +193,13 @@ function emailAlert (alert) {
|
|||
case STALE:
|
||||
const stuckAge = prettyMs(alert.age, {compact: true, verbose: true})
|
||||
return `Machine is stuck on ${alert.state} screen for ${stuckAge}`
|
||||
case LOW_BALANCE:
|
||||
case LOW_CRYPTO_BALANCE:
|
||||
const balance = formatCurrency(alert.fiatBalance.balance, alert.fiatCode)
|
||||
return `Low balance of ${balance} in ${alert.cryptoCode} wallet`
|
||||
return `Low balance in ${alert.cryptoCode} [${balance}]`
|
||||
case CASH_BOX_FULL:
|
||||
return `Cash box full on ${alert.machineName} [${alert.notes} banknotes]`
|
||||
case LOW_CASH_OUT:
|
||||
return `Cassette for ${alert.denomination} ${alert.fiatCode} low [${alert.notes} banknotes]`
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue