chore: server code formatting
This commit is contained in:
parent
aedabcbdee
commit
68517170e2
234 changed files with 9824 additions and 6195 deletions
|
|
@ -11,10 +11,10 @@ const {
|
|||
CASH_BOX_FULL,
|
||||
LOW_CASH_OUT,
|
||||
LOW_RECYCLER_STACKER,
|
||||
SECURITY
|
||||
SECURITY,
|
||||
} = require('./codes')
|
||||
|
||||
function alertSubject (alertRec, config) {
|
||||
function alertSubject(alertRec, config) {
|
||||
let alerts = []
|
||||
|
||||
if (config.balance) {
|
||||
|
|
@ -27,11 +27,16 @@ function alertSubject (alertRec, config) {
|
|||
|
||||
if (alerts.length === 0) return null
|
||||
|
||||
const alertTypes = _.flow(_.map('code'), _.uniq, _.map(utils.codeDisplay), _.sortBy(o => o))(alerts)
|
||||
const alertTypes = _.flow(
|
||||
_.map('code'),
|
||||
_.uniq,
|
||||
_.map(utils.codeDisplay),
|
||||
_.sortBy(o => o),
|
||||
)(alerts)
|
||||
return '[Lamassu] Errors reported: ' + alertTypes.join(', ')
|
||||
}
|
||||
|
||||
function printEmailAlerts (alertRec, config) {
|
||||
function printEmailAlerts(alertRec, config) {
|
||||
let body = 'Errors were reported by your Lamassu Machines.\n'
|
||||
|
||||
if (config.balance && alertRec.general.length !== 0) {
|
||||
|
|
@ -50,30 +55,39 @@ function printEmailAlerts (alertRec, config) {
|
|||
return body
|
||||
}
|
||||
|
||||
function emailAlerts (alerts) {
|
||||
function emailAlerts(alerts) {
|
||||
return _.join('\n', _.map(emailAlert, alerts)) + '\n'
|
||||
}
|
||||
|
||||
function emailAlert (alert) {
|
||||
function emailAlert(alert) {
|
||||
switch (alert.code) {
|
||||
case PING:
|
||||
if (alert.age) {
|
||||
const pingAge = utils.formatAge(alert.age, { compact: true, verbose: true })
|
||||
const pingAge = utils.formatAge(alert.age, {
|
||||
compact: true,
|
||||
verbose: true,
|
||||
})
|
||||
return `Machine down for ${pingAge}`
|
||||
}
|
||||
return 'Machine down for a while.'
|
||||
case STALE: {
|
||||
const stuckAge = utils.formatAge(alert.age, { compact: true, verbose: true })
|
||||
const stuckAge = utils.formatAge(alert.age, {
|
||||
compact: true,
|
||||
verbose: true,
|
||||
})
|
||||
return `Machine is stuck on ${alert.state} screen for ${stuckAge}`
|
||||
}
|
||||
case LOW_CRYPTO_BALANCE: {
|
||||
const balance = utils.formatCurrency(alert.fiatBalance.balance, alert.fiatCode)
|
||||
const balance = utils.formatCurrency(
|
||||
alert.fiatBalance.balance,
|
||||
alert.fiatCode,
|
||||
)
|
||||
return `Low balance in ${alert.cryptoCode} [${balance}]`
|
||||
}
|
||||
case HIGH_CRYPTO_BALANCE: {
|
||||
const highBalance = utils.formatCurrency(
|
||||
alert.fiatBalance.balance,
|
||||
alert.fiatCode
|
||||
alert.fiatCode,
|
||||
)
|
||||
return `High balance in ${alert.cryptoCode} [${highBalance}]`
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue