fix: added missing lodash dependency to accounts lib

fix: don't prepend '+' when using a friendly name with Twilio

fix: consider that the phone number may contain whitespaces

fix: removed duplicated import on accounts.js

fix: replaced isNan with lodash's _.isNumber

fix: _isNumber logic was inverted
This commit is contained in:
Liordino Neto 2020-07-03 17:50:24 -03:00 committed by Josh Harvey
parent 8564c8b727
commit 72a1b798f8

View file

@ -14,7 +14,8 @@ function sendMessage (account, rec) {
const client = twilio(account.accountSid, account.authToken)
const body = rec.sms.body
const _toNumber = rec.sms.toNumber || account.toNumber
const from = _.startsWith('+')(account.fromNumber)
const from = (_.startsWith('+')(account.fromNumber)
|| !_.isNumber(String(account.fromNumber).replace(/\s/g,'')))
? account.fromNumber : `+${account.fromNumber}`
const opts = {