Skip to content

Commit

Permalink
Merge pull request #1396 from WideChat/ear_whatsapp_template
Browse files Browse the repository at this point in the history
[FIX] use camelCase and proper From number when also sending messageServiceSid
  • Loading branch information
bhardwajaditya authored Sep 6, 2023
2 parents 1573ff7 + 75f691e commit 8680417
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions apps/meteor/app/sms/server/services/twilio.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,35 +156,36 @@ class Twilio {
body = TAPi18n.__('Location', { lng: defaultLanguage });
}

let ContentSid;
let ContentVariables;
let MessagingServiceSid;
let contentSid;
let contentVariables;
let messagingServiceSid;
if (extraData && extraData.contentSid) {
ContentSid = extraData.contentSid;
MessagingServiceSid = extraData.messagingServiceSid;
contentSid = extraData.contentSid;
messagingServiceSid = extraData.messagingServiceSid;
}

if (extraData && extraData.contentVariables) {
ContentVariables = JSON.stringify(extraData.contentVariables);
contentVariables = JSON.stringify(extraData.contentVariables);
}

if (!messageQueue[toNumber]) {
messageQueue[toNumber] = [];
}

if (!body && !mediaUrl && !ContentSid) {
if (!body && !mediaUrl && !contentSid) {
return;
}

messageQueue[toNumber].push({
to: toNumber,
from: ContentSid ? MessagingServiceSid : fromNumber,
// from: contentSid ? messagingServiceSid : fromNumber,
from: fromNumber,
body,
...(mediaUrl && { mediaUrl }),
...(persistentAction && { persistentAction }),
...(ContentSid && { ContentSid }),
...(MessagingServiceSid && { MessagingServiceSid }),
...(ContentVariables && { ContentVariables }),
...(contentSid && { contentSid }),
...(messagingServiceSid && { messagingServiceSid }),
...(contentVariables && { contentVariables }),
});

SystemLogger.debug('Twillio Payload:', messageQueue[toNumber]);
Expand Down

0 comments on commit 8680417

Please sign in to comment.