Skip to content

Commit

Permalink
fix: filter out invalid system message types
Browse files Browse the repository at this point in the history
  • Loading branch information
aleksandernsilva committed Feb 29, 2024
1 parent 12d0d02 commit 4b120bf
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/livechat/src/widget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ export const VALID_CALLBACKS = [
'no-agent-online',
];

const VALID_SYSTEM_MESSAGES = ['uj', 'ul', 'livechat-close', 'livechat-started', 'livechat_transfer_history', 'livechat_webrtc_video_call'];

const callbacks = mitt();

function registerCallback(eventName: string, fn: () => unknown) {
Expand Down Expand Up @@ -352,7 +354,10 @@ function setHiddenSystemMessages(hidden: StoreState['iframe']['hiddenSystemMessa
throw new Error('Error: Invalid parameters. Value must be an array of strings');
}

callHook('setHiddenSystemMessages', hidden);
callHook(
'setHiddenSystemMessages',
hidden.filter((h) => VALID_SYSTEM_MESSAGES.includes(h)),
);
}

function initialize(initParams: Partial<InitializeParams>) {
Expand Down

0 comments on commit 4b120bf

Please sign in to comment.