Skip to content

Commit

Permalink
change reference of facebook to messenger
Browse files Browse the repository at this point in the history
  • Loading branch information
mythilytm committed Oct 24, 2024
1 parent 2d957a5 commit 9fc0048
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions functions/getProfileFlagsForIdentifier.protected.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,15 @@ const trimHyphens = (s: string) => s.replaceAll('-', '');
const phoneNumberStandardization = (s: string) =>
[trimSpaces, trimHyphens].reduce((accum, f) => f(accum), s);
type TransformIdentifierFunction = (c: string) => string;
const channelTransformations: { [k: string]: TransformIdentifierFunction[] } = {
const channelTransformations: { [k in string]: TransformIdentifierFunction[] } = {
voice: [phoneNumberStandardization],
sms: [phoneNumberStandardization],
whatsapp: [(s) => s.replace('whatsapp:', ''), phoneNumberStandardization],
modica: [(s) => s.replace('modica:', ''), phoneNumberStandardization],
facebook: [(s) => s.replace('messenger:', '')],
messenger: [(s) => s.replace('messenger:', '')],
instagram: [],
line: [],
telegram: [],
web: [],
};

Expand All @@ -119,6 +120,10 @@ export const getIdentifier = (trigger: Event['trigger'], channelType?: string):
}

if (isConversationTrigger(trigger) && channelType) {
if (!channelTransformations[channelType] || !channelType) {
console.error(`Channel type ${channelType} is not supported`);
throw new Error(`Channel type ${channelType} is not supported`);
}
return channelTransformations[channelType].reduce(
(accum, f) => f(accum),
trigger.conversation.Author,
Expand Down

0 comments on commit 9fc0048

Please sign in to comment.