From 6e820fc962b270eefab63110f63d26300ca5139f Mon Sep 17 00:00:00 2001 From: Aditya Bhardwaj Date: Tue, 19 Sep 2023 19:09:22 +0530 Subject: [PATCH 1/2] Extract message service SID from incoming message and save to room --- apps/meteor/app/livechat/imports/server/rest/sms.js | 1 + apps/meteor/app/livechat/server/sendMessageBySMS.js | 5 ++--- apps/meteor/app/sms/server/services/twilio.js | 3 ++- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/apps/meteor/app/livechat/imports/server/rest/sms.js b/apps/meteor/app/livechat/imports/server/rest/sms.js index 65a2d248ff30..deb27cb73edd 100644 --- a/apps/meteor/app/livechat/imports/server/rest/sms.js +++ b/apps/meteor/app/livechat/imports/server/rest/sms.js @@ -101,6 +101,7 @@ API.v1.addRoute('livechat/sms-incoming/:service', { roomInfo: { sms: { from: sms.to, + messaging_service_sid: sms.messagingServiceSid, }, source: { type: OmnichannelSourceType.SMS, diff --git a/apps/meteor/app/livechat/server/sendMessageBySMS.js b/apps/meteor/app/livechat/server/sendMessageBySMS.js index e561c5faff06..e6ef43c46a93 100644 --- a/apps/meteor/app/livechat/server/sendMessageBySMS.js +++ b/apps/meteor/app/livechat/server/sendMessageBySMS.js @@ -66,9 +66,8 @@ callbacks.add( extraData = Object.assign({}, extraData, { contentVariables }); } - if (message.customFields && message.customFields.messagingServiceSid) { - const { messagingServiceSid } = message.customFields; - extraData = Object.assign({}, extraData, { messagingServiceSid }); + if (room.sms.messaging_service_sid) { + extraData = Object.assign({}, extraData, { messagingServiceSid: room.sms.messaging_service_sid }); } const SMSService = SMS.getService(settings.get('SMS_Service')); diff --git a/apps/meteor/app/sms/server/services/twilio.js b/apps/meteor/app/sms/server/services/twilio.js index 2579a9622c40..1a00d2450d99 100644 --- a/apps/meteor/app/sms/server/services/twilio.js +++ b/apps/meteor/app/sms/server/services/twilio.js @@ -57,6 +57,7 @@ class Twilio { parse(data) { let numMedia = 0; + SystemLogger.debug('Incoming Twilio message: ', data); const returnData = { from: data.From, @@ -74,6 +75,7 @@ class Twilio { fromZip: data.FromZip, fromLatitude: data.Latitude, fromLongitude: data.Longitude, + messagingServiceSid: data.MessagingServiceSid, }, }; @@ -178,7 +180,6 @@ class Twilio { messageQueue[toNumber].push({ to: toNumber, - // from: contentSid ? messagingServiceSid : fromNumber, from: fromNumber, body, ...(mediaUrl && { mediaUrl }), From 6bdecf34cf259a6cde5ad40717cb2f602f606965 Mon Sep 17 00:00:00 2001 From: Aditya Bhardwaj Date: Wed, 20 Sep 2023 21:44:54 +0530 Subject: [PATCH 2/2] Fix missing message service sid --- apps/meteor/app/livechat/imports/server/rest/sms.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/meteor/app/livechat/imports/server/rest/sms.js b/apps/meteor/app/livechat/imports/server/rest/sms.js index deb27cb73edd..364d19cd772f 100644 --- a/apps/meteor/app/livechat/imports/server/rest/sms.js +++ b/apps/meteor/app/livechat/imports/server/rest/sms.js @@ -101,7 +101,7 @@ API.v1.addRoute('livechat/sms-incoming/:service', { roomInfo: { sms: { from: sms.to, - messaging_service_sid: sms.messagingServiceSid, + messaging_service_sid: sms.extra.messagingServiceSid, }, source: { type: OmnichannelSourceType.SMS,