fix twilio bug; update packages
This commit is contained in:
parent
4b0e4065ca
commit
95aaee4037
4 changed files with 3270 additions and 8 deletions
|
|
@ -1,4 +1,4 @@
|
|||
const Client = require('twilio')
|
||||
const twilio = require('twilio')
|
||||
const _ = require('lodash/fp')
|
||||
|
||||
const NAME = 'Twilio'
|
||||
|
|
@ -7,7 +7,7 @@ const BAD_NUMBER_CODES = [21201, 21202, 21211, 21214, 21216, 21217, 21219, 21408
|
|||
21610, 21612, 21614, 21608]
|
||||
|
||||
function sendMessage (account, rec) {
|
||||
const client = Client(account.accountSid, account.authToken)
|
||||
const client = twilio(account.accountSid, account.authToken)
|
||||
const body = rec.sms.body
|
||||
const _toNumber = rec.sms.toNumber || account.toNumber
|
||||
|
||||
|
|
@ -17,7 +17,7 @@ function sendMessage (account, rec) {
|
|||
from: account.fromNumber
|
||||
}
|
||||
|
||||
return client.sendMessage(opts)
|
||||
return client.messages.create(opts)
|
||||
.catch(err => {
|
||||
if (_.includes(err.code, BAD_NUMBER_CODES)) {
|
||||
const badNumberError = new Error(err.message)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue