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:
Sérgio Salgado 2021-07-30 05:28:03 +01:00
parent 3480bbf8f7
commit 54b73b95b4
10 changed files with 444 additions and 95 deletions

View file

@ -361,19 +361,19 @@ function plugins (settings, deviceId) {
const phone = tx.phone
const timestamp = dateFormat(new Date(), 'UTC:HH:MM Z')
const rec = {
sms: {
toNumber: phone,
body: `Your cash is waiting! Go to the Cryptomat and press Redeem within 24 hours. [${timestamp}]`
}
}
return sms.getCashOutReadySms(deviceId, phone, code)
.then(msg => {
const rec = {
sms: msg
}
return sms.sendMessage(settings, rec)
.then(() => {
const sql = 'update cash_out_txs set notified=$1 where id=$2'
const values = [true, tx.id]
return sms.sendMessage(settings, rec)
.then(() => {
const sql = 'update cash_out_txs set notified=$1 where id=$2'
const values = [true, tx.id]
return db.none(sql, values)
return db.none(sql, values)
})
})
}
@ -723,15 +723,15 @@ function plugins (settings, deviceId) {
? '123'
: randomCode()
const rec = {
sms: {
toNumber: phone,
body: 'Your cryptomat code: ' + code
}
}
return sms.sendMessage(settings, rec)
.then(() => code)
return sms.getPhoneCodeSms(deviceId, phone, code)
.then(msg => {
const rec = {
sms: msg
}
return sms.sendMessage(settings, rec)
.then(() => code)
})
}
function sweepHdRow (row) {