diff --git a/wai-server/core/handler/whatsappHandler.js b/wai-server/core/handler/whatsappHandler.js index 42cb78b..a36047c 100644 --- a/wai-server/core/handler/whatsappHandler.js +++ b/wai-server/core/handler/whatsappHandler.js @@ -24,8 +24,9 @@ const timeField = { saved: 'createTime', pending: 'createTime', sent: 'sendTime' const statusMapped = { saved: 'accepted', pending: 'accepted', sent: 'sent', delivered: 'delivered', read: 'read', failed: 'failed' }; const directionField = { 'message:received': 'inbound', 'message:updated': 'outbound' }; const directionPrefix = { inbound: 'in_', outbound: 'out_' }; +const directionIdUserPrefix = { inbound: 'to', outbound: 'from' }; -const uniqueMsgId = msg => (msg.id && msg.direction ? `${directionPrefix[msg.direction]}${msg.to.replace('+', '')}_${msg.id}` : undefined); +const uniqueMsgId = msg => (msg.id && msg.direction ? `${directionPrefix[msg.direction]}${msg[directionIdUserPrefix[msg.direction]].replace('+', '')}_${msg.id}` : undefined); /** * @returns {Object} webhookBody