more refactoring
This commit is contained in:
parent
8acbc90dbd
commit
9a9c927801
6 changed files with 30 additions and 30 deletions
|
|
@ -336,7 +336,7 @@ exports.trade = function trade (deviceId, rawTrade) {
|
|||
exports.stateChange = function stateChange (deviceId, deviceTime, rec, cb) {
|
||||
const event = {
|
||||
id: rec.uuid,
|
||||
fingerprint: deviceId,
|
||||
deviceId: deviceId,
|
||||
eventType: 'stateChange',
|
||||
note: JSON.stringify({state: rec.state, isIdle: rec.isIdle, txId: rec.txId}),
|
||||
deviceTime: deviceTime
|
||||
|
|
@ -347,7 +347,7 @@ exports.stateChange = function stateChange (deviceId, deviceTime, rec, cb) {
|
|||
exports.recordPing = function recordPing (deviceId, deviceTime, rec, cb) {
|
||||
const event = {
|
||||
id: uuid.v4(),
|
||||
fingerprint: deviceId,
|
||||
deviceId: deviceId,
|
||||
eventType: 'ping',
|
||||
note: JSON.stringify({state: rec.state, isIdle: rec.idle === 'true', txId: rec.txId}),
|
||||
deviceTime: deviceTime
|
||||
|
|
@ -691,15 +691,15 @@ function sendNoAlerts () {
|
|||
function checkNotification () {
|
||||
return notifier.checkStatus()
|
||||
.then(alertRec => {
|
||||
const fingerprint = notifier.alertFingerprint(alertRec)
|
||||
if (!fingerprint) {
|
||||
const currentAlertFingerprint = notifier.alertFingerprint(alertRec)
|
||||
if (!currentAlertFingerprint) {
|
||||
const inAlert = !!alertFingerprint
|
||||
alertFingerprint = null
|
||||
lastAlertTime = null
|
||||
if (inAlert) return sendNoAlerts()
|
||||
}
|
||||
|
||||
const alertChanged = fingerprint === alertFingerprint &&
|
||||
const alertChanged = currentAlertFingerprint === alertFingerprint &&
|
||||
lastAlertTime - Date.now() < ALERT_SEND_INTERVAL
|
||||
if (alertChanged) return
|
||||
|
||||
|
|
@ -713,7 +713,7 @@ function checkNotification () {
|
|||
body: notifier.printEmailAlerts(alertRec)
|
||||
}
|
||||
}
|
||||
alertFingerprint = fingerprint
|
||||
alertFingerprint = currentAlertFingerprint
|
||||
lastAlertTime = Date.now()
|
||||
|
||||
return sendMessage(rec)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue