Skip to content

Commit

Permalink
fix: partial implementation of getIdentifier function resulted in err…
Browse files Browse the repository at this point in the history
…ors for several channels [CHI-2605] (#586)
  • Loading branch information
GPaoloni authored Feb 20, 2024
1 parent b7b01fc commit ad3f0a3
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion functions/getProfileFlagsForIdentifier.protected.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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');
Expand Down

0 comments on commit ad3f0a3

Please sign in to comment.