WIP
This commit is contained in:
parent
7bb071fc95
commit
ee0eecbd30
3 changed files with 47 additions and 4 deletions
18
lib/email.js
Normal file
18
lib/email.js
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
const configManager = require('./config-manager')
|
||||||
|
const settingsLoader = require('./settings-loader')
|
||||||
|
|
||||||
|
function sendMessage (rec) {
|
||||||
|
return Promise.resolve()
|
||||||
|
.then(() => {
|
||||||
|
const settings = settingsLoader.settings
|
||||||
|
const pluginCode = configManager.unscoped(settings.config).extraServices.email
|
||||||
|
|
||||||
|
if (!pluginCode) throw new Error('No email plugin defined')
|
||||||
|
const account = settings.accounts.plugin
|
||||||
|
const plugin = require('lamassu-' + plugin)
|
||||||
|
|
||||||
|
return plugin.sendMessage(account, rec)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports({sendMessage})
|
||||||
|
|
@ -408,7 +408,14 @@ function executeTradesForMarket (settings, fiatCode, cryptoCode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function sendMessage (rec) {
|
function sendMessage (rec) {
|
||||||
return Promise.all([sms.sendMessage(rec), email.sendMessage(rec)])
|
const settings = settingsLoader.settings
|
||||||
|
const notifications = configManager.unscoped(settings.config).notifications
|
||||||
|
|
||||||
|
let promises = []
|
||||||
|
if (notifications.notificationsEmailEnabled) promises.push(email.sendMessage(rec))
|
||||||
|
if (notifications.notificationsSMSEnabled) promises.push(sms.sendMessage(rec))
|
||||||
|
|
||||||
|
return Promise.all(promises)
|
||||||
}
|
}
|
||||||
|
|
||||||
function sendNoAlerts () {
|
function sendNoAlerts () {
|
||||||
|
|
@ -503,9 +510,9 @@ function startCheckingNotification (config) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function getPhoneCode (phone) {
|
function getPhoneCode (phone) {
|
||||||
return sms.name()
|
return sms.code()
|
||||||
.then(name => {
|
.then(pluginCode => {
|
||||||
const code = name === 'MockSMS'
|
const code = pluginCode === 'mock-sms'
|
||||||
? '123'
|
? '123'
|
||||||
: BigNumber.random().toFixed(6).slice(2)
|
: BigNumber.random().toFixed(6).slice(2)
|
||||||
|
|
||||||
|
|
|
||||||
18
lib/sms.js
Normal file
18
lib/sms.js
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
const configManager = require('./config-manager')
|
||||||
|
const settingsLoader = require('./settings-loader')
|
||||||
|
|
||||||
|
function sendMessage (rec) {
|
||||||
|
return Promise.resolve()
|
||||||
|
.then(() => {
|
||||||
|
const settings = settingsLoader.settings
|
||||||
|
const pluginCode = configManager.unscoped(settings.config).extraServices.sms
|
||||||
|
|
||||||
|
if (!pluginCode) throw new Error('No sms plugin defined')
|
||||||
|
const account = settings.accounts.plugin
|
||||||
|
const plugin = require('lamassu-' + plugin)
|
||||||
|
|
||||||
|
return plugin.sendMessage(account, rec)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports({sendMessage})
|
||||||
Loading…
Add table
Add a link
Reference in a new issue