From 72a1b798f838670f79639e4e4c4130d846b47e0e Mon Sep 17 00:00:00 2001 From: Liordino Neto Date: Fri, 3 Jul 2020 17:50:24 -0300 Subject: [PATCH] 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 --- lib/plugins/sms/twilio/twilio.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/plugins/sms/twilio/twilio.js b/lib/plugins/sms/twilio/twilio.js index 68a7ddb7..cedd6952 100644 --- a/lib/plugins/sms/twilio/twilio.js +++ b/lib/plugins/sms/twilio/twilio.js @@ -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 = {