WIP; plugins
This commit is contained in:
parent
bd3441adfb
commit
a9ded1ddf2
2 changed files with 17 additions and 7 deletions
|
|
@ -212,6 +212,12 @@
|
||||||
"display": "SMS",
|
"display": "SMS",
|
||||||
"fieldType": "account",
|
"fieldType": "account",
|
||||||
"fieldClass": "sms"
|
"fieldClass": "sms"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"code": "lowBalanceThreshold",
|
||||||
|
"display": "Low Balance Threshold",
|
||||||
|
"fieldType": "integer",
|
||||||
|
"fieldClass": null
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -690,12 +690,16 @@ exports.getcryptoCodes = function getcryptoCodes () {
|
||||||
}
|
}
|
||||||
|
|
||||||
function sendMessage (rec) {
|
function sendMessage (rec) {
|
||||||
const pluginTypes = cachedConfig.exchanges.plugins.current.notify
|
const pluginPromises = []
|
||||||
const pluginPromises = pluginTypes.map(pluginType => {
|
if (!cachedConfig.notifications.notificationsEnabled) return Promise.all([])
|
||||||
if (pluginType === 'email') return emailPlugin.sendMessage(rec)
|
|
||||||
if (pluginType === 'sms') return smsPlugin.sendMessage(rec)
|
if (cachedConfig.notifications.notificationsEmailEnabled) {
|
||||||
throw new Error('No such plugin type: ' + pluginType)
|
pluginPromises.push(emailPlugin.sendMessage(rec))
|
||||||
})
|
}
|
||||||
|
|
||||||
|
if (cachedConfig.notifications.notificationsSMSEnabled) {
|
||||||
|
pluginPromises.push(smsPlugin.sendMessage(rec))
|
||||||
|
}
|
||||||
|
|
||||||
return Promise.all(pluginPromises)
|
return Promise.all(pluginPromises)
|
||||||
}
|
}
|
||||||
|
|
@ -770,7 +774,7 @@ function checkBalances () {
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.startCheckingNotification = function startCheckingNotification () {
|
exports.startCheckingNotification = function startCheckingNotification () {
|
||||||
const config = cachedConfig.exchanges.plugins.settings.notifier
|
const config = cachedConfig.notifications
|
||||||
notifier.init(db, checkBalances, config)
|
notifier.init(db, checkBalances, config)
|
||||||
checkNotification()
|
checkNotification()
|
||||||
setInterval(checkNotification, CHECK_NOTIFICATION_INTERVAL)
|
setInterval(checkNotification, CHECK_NOTIFICATION_INTERVAL)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue