refactor: unify sms creation into a single function
This commit is contained in:
parent
ee8c46b51e
commit
ed7c515993
2 changed files with 19 additions and 31 deletions
|
|
@ -361,15 +361,15 @@ function plugins (settings, deviceId) {
|
|||
|
||||
const phone = tx.phone
|
||||
const timestamp = dateFormat(new Date(), 'UTC:HH:MM Z')
|
||||
return sms.getCashOutReadySms(phone, timestamp)
|
||||
.then(msg => {
|
||||
return sms.getSms('cash_out_dispense_ready', phone, { timestamp })
|
||||
.then(smsObj => {
|
||||
const rec = {
|
||||
sms: msg
|
||||
sms: smsObj
|
||||
}
|
||||
|
||||
return sms.sendMessage(settings, rec)
|
||||
.then(() => {
|
||||
const sql = 'update cash_out_txs set notified=$1 where id=$2'
|
||||
const sql = 'UPDATE cash_out_txs SET notified=$1 WHERE id=$2'
|
||||
const values = [true, tx.id]
|
||||
|
||||
return db.none(sql, values)
|
||||
|
|
@ -723,10 +723,10 @@ function plugins (settings, deviceId) {
|
|||
? '123'
|
||||
: randomCode()
|
||||
|
||||
return sms.getPhoneCodeSms(phone, code)
|
||||
.then(msg => {
|
||||
return sms.getSms('sms_code', phone, { code })
|
||||
.then(smsObj => {
|
||||
const rec = {
|
||||
sms: msg
|
||||
sms: smsObj
|
||||
}
|
||||
|
||||
return sms.sendMessage(settings, rec)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue