WIP
This commit is contained in:
parent
76e53dfc74
commit
8a87c7579d
3 changed files with 40 additions and 1 deletions
|
|
@ -31,6 +31,7 @@ module.exports = function (options) {
|
|||
|
||||
plugins.configure(config)
|
||||
plugins.startPolling()
|
||||
plugins.startCheckingNotification()
|
||||
})
|
||||
|
||||
lamassuConfig.on('configUpdate', function () {
|
||||
|
|
|
|||
|
|
@ -2,15 +2,19 @@
|
|||
|
||||
var _ = require('lodash')
|
||||
var async = require('async')
|
||||
var R = require('ramda')
|
||||
|
||||
var BigNumber = require('bignumber.js')
|
||||
|
||||
var logger = require('./logger')
|
||||
var notifier = require('./notifier')
|
||||
|
||||
var argv = require('minimist')(process.argv.slice(2))
|
||||
|
||||
var uuid = require('node-uuid')
|
||||
var tradeIntervals = {}
|
||||
|
||||
var CHECK_NOTIFICATION_INTERVAL = 60 * 1000
|
||||
var POLLING_RATE = 60 * 1000 // poll each minute
|
||||
var REAP_RATE = 2 * 1000
|
||||
var PENDING_TIMEOUT = 70 * 1000
|
||||
|
|
@ -630,7 +634,7 @@ exports.getcryptoCodes = function getcryptoCodes () {
|
|||
return cryptoCodes
|
||||
}
|
||||
|
||||
exports.sendMessage = function sendMessage (rec, cb) {
|
||||
function sendMessage (rec, cb) {
|
||||
console.log('DEBUG5')
|
||||
cb = cb || function () {}
|
||||
console.log(cachedConfig.exchanges.plugins.current.notify)
|
||||
|
|
@ -644,3 +648,35 @@ exports.sendMessage = function sendMessage (rec, cb) {
|
|||
})
|
||||
return Promise.all(pluginPromises)
|
||||
}
|
||||
|
||||
function checkNotification () {
|
||||
notifier.checkStatus()
|
||||
.then(function (alerts) {
|
||||
if (alerts.length === 0) return
|
||||
|
||||
// var devices = R.keys(alerts.devices)
|
||||
var alertRecs = alerts.general
|
||||
R.keys(alerts.devices).forEach(function (device) {
|
||||
alertRecs = R.append(alerts.devices[device], alertRecs)
|
||||
})
|
||||
var alertTypes = alertRecs.pluck('code', alerts)
|
||||
var body = ''
|
||||
var rec = {
|
||||
sms: {
|
||||
body: '[Lamassu] Errors reported: ' + alertTypes.join(', ')
|
||||
},
|
||||
email: {
|
||||
subject: '[Lamassu] Errors reported: ' + alertTypes.join(', '),
|
||||
body: body
|
||||
}
|
||||
}
|
||||
sendMessage(rec)
|
||||
})
|
||||
.catch(function (err) {
|
||||
logger.error(err)
|
||||
})
|
||||
}
|
||||
|
||||
exports.startCheckingNotification = function startCheckingNotification () {
|
||||
setInterval(checkNotification, CHECK_NOTIFICATION_INTERVAL)
|
||||
}
|
||||
|
|
|
|||
2
todo.txt
2
todo.txt
|
|
@ -2,3 +2,5 @@
|
|||
- integrate email and sms into notifications
|
||||
- run notifications from server
|
||||
- don't keep sending notifications when state persists -- keep variable in memory
|
||||
- add toEmail, toNumber to db
|
||||
- finish up notification emails
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue