From ad3f0a3ea2caf7851bd1654ffa41b8bf9bf9483b Mon Sep 17 00:00:00 2001 From: Gianfranco Date: Tue, 20 Feb 2024 17:19:17 -0300 Subject: [PATCH] fix: partial implementation of getIdentifier function resulted in errors for several channels [CHI-2605] (#586) --- functions/getProfileFlagsForIdentifier.protected.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/functions/getProfileFlagsForIdentifier.protected.ts b/functions/getProfileFlagsForIdentifier.protected.ts index d58a9bdb..cc450ad2 100644 --- a/functions/getProfileFlagsForIdentifier.protected.ts +++ b/functions/getProfileFlagsForIdentifier.protected.ts @@ -43,7 +43,7 @@ type ChatTrigger = { }; }; }; -const isChatTrigger = (obj: any): obj is VoiceTrigger => +const isChatTrigger = (obj: any): obj is ChatTrigger => obj && obj.message && typeof obj.message === 'object'; type VoiceTrigger = { @@ -83,9 +83,14 @@ export const getIdentifier = (trigger: Event['trigger']) => { if (trigger.message.ChannelAttributes.channel_type === 'whatsapp') { return trigger.message.ChannelAttributes.from.replace('whatsapp:', ''); } + if (trigger.message.ChannelAttributes.channel_type === 'modica') { + return trigger.message.ChannelAttributes.from.replace('modica:', ''); + } if (trigger.message.ChannelAttributes.channel_type === 'web') { return getContactValueFromWebchat(trigger); } + + return trigger.message.ChannelAttributes.from; } throw new Error('Trigger is none VoiceTrigger nor ChatTrigger');