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",
|
||||
"fieldType": "account",
|
||||
"fieldClass": "sms"
|
||||
},
|
||||
{
|
||||
"code": "lowBalanceThreshold",
|
||||
"display": "Low Balance Threshold",
|
||||
"fieldType": "integer",
|
||||
"fieldClass": null
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -690,12 +690,16 @@ exports.getcryptoCodes = function getcryptoCodes () {
|
|||
}
|
||||
|
||||
function sendMessage (rec) {
|
||||
const pluginTypes = cachedConfig.exchanges.plugins.current.notify
|
||||
const pluginPromises = pluginTypes.map(pluginType => {
|
||||
if (pluginType === 'email') return emailPlugin.sendMessage(rec)
|
||||
if (pluginType === 'sms') return smsPlugin.sendMessage(rec)
|
||||
throw new Error('No such plugin type: ' + pluginType)
|
||||
})
|
||||
const pluginPromises = []
|
||||
if (!cachedConfig.notifications.notificationsEnabled) return Promise.all([])
|
||||
|
||||
if (cachedConfig.notifications.notificationsEmailEnabled) {
|
||||
pluginPromises.push(emailPlugin.sendMessage(rec))
|
||||
}
|
||||
|
||||
if (cachedConfig.notifications.notificationsSMSEnabled) {
|
||||
pluginPromises.push(smsPlugin.sendMessage(rec))
|
||||
}
|
||||
|
||||
return Promise.all(pluginPromises)
|
||||
}
|
||||
|
|
@ -770,7 +774,7 @@ function checkBalances () {
|
|||
}
|
||||
|
||||
exports.startCheckingNotification = function startCheckingNotification () {
|
||||
const config = cachedConfig.exchanges.plugins.settings.notifier
|
||||
const config = cachedConfig.notifications
|
||||
notifier.init(db, checkBalances, config)
|
||||
checkNotification()
|
||||
setInterval(checkNotification, CHECK_NOTIFICATION_INTERVAL)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue