feat: scripting-like tags on custom sms content
feat: add created column to custom_messages feat: custom message dynamic validators and testing feat: delete custom sms feat: employ custom sms to existing events
This commit is contained in:
parent
3480bbf8f7
commit
54b73b95b4
10 changed files with 444 additions and 95 deletions
70
lib/sms.js
70
lib/sms.js
|
|
@ -1,6 +1,67 @@
|
|||
const ph = require('./plugin-helper')
|
||||
const argv = require('minimist')(process.argv.slice(2))
|
||||
const { utils: coinUtils } = require('lamassu-coins')
|
||||
const _ = require('lodash/fp')
|
||||
|
||||
const customSms = require('./custom-sms')
|
||||
|
||||
function getPhoneCodeSms (deviceId, phone, code) {
|
||||
return Promise.all([
|
||||
customSms.getCommonCustomMessages('sms_code'),
|
||||
customSms.getMachineCustomMessages('sms_code', deviceId)
|
||||
])
|
||||
.then(([commonMsg, machineMsg]) => {
|
||||
if (!_.isNil(machineMsg)) {
|
||||
const messageContent = _.replace('#code', code, machineMsg.message)
|
||||
return {
|
||||
toNumber: phone,
|
||||
body: messageContent
|
||||
}
|
||||
}
|
||||
|
||||
if (!_.isNil(commonMsg)) {
|
||||
const messageContent = _.replace('#code', code, commonMsg.message)
|
||||
return {
|
||||
toNumber: phone,
|
||||
body: messageContent
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
toNumber: phone,
|
||||
body: `Your cryptomat code: ${code}`
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function getCashOutReadySms (deviceId, phone, timestamp) {
|
||||
return Promise.all([
|
||||
customSms.getCommonCustomMessages('cash_out_dispense_ready'),
|
||||
customSms.getMachineCustomMessages('cash_out_dispense_ready', deviceId)
|
||||
])
|
||||
.then(([commonMsg, machineMsg]) => {
|
||||
if (!_.isNil(machineMsg)) {
|
||||
const messageContent = _.replace('#timestamp', timestamp, machineMsg.message)
|
||||
return {
|
||||
toNumber: phone,
|
||||
body: messageContent
|
||||
}
|
||||
}
|
||||
|
||||
if (!_.isNil(commonMsg)) {
|
||||
const messageContent = _.replace('#timestamp', timestamp, commonMsg.message)
|
||||
return {
|
||||
toNumber: phone,
|
||||
body: messageContent
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
toNumber: phone,
|
||||
body: `Your cash is waiting! Go to the Cryptomat and press Redeem within 24 hours. [${timestamp}]`
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function getPlugin (settings) {
|
||||
const pluginCode = argv.mockSms ? 'mock-sms' : 'twilio'
|
||||
|
|
@ -91,4 +152,11 @@ function formatSmsReceipt (data, options) {
|
|||
return request
|
||||
}
|
||||
|
||||
module.exports = { sendMessage, formatSmsReceipt, getLookup, toCryptoUnits }
|
||||
module.exports = {
|
||||
getPhoneCodeSms,
|
||||
getCashOutReadySms,
|
||||
sendMessage,
|
||||
getLookup,
|
||||
formatSmsReceipt,
|
||||
toCryptoUnits
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue