Skip to content

Commit

Permalink
fix set
Browse files Browse the repository at this point in the history
  • Loading branch information
gabriellsh committed Oct 18, 2023
1 parent 211dfc2 commit e4ee8ce
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,21 @@ type DefaultValues = {
emoji: string;
};

const toArray = (value: string | Array<string>): Array<string> => {
if (typeof value === 'string') {
return [value];
}
return value;
};

export const processWebhookMessage = async function (
messageObj: Payload,
user: IUser & { username: RequiredField<IUser, 'username'> },
defaultValues: DefaultValues = { channel: '', alias: '', avatar: '', emoji: '' },
) {
const sentData = [];

const channels: Array<string> = [...new Set(messageObj.channel || messageObj.roomId || defaultValues.channel)];
const channels: Array<string> = [...new Set(toArray(messageObj.channel || messageObj.roomId || defaultValues.channel))];

for await (const channel of channels) {
const channelType = channel[0];
Expand Down

0 comments on commit e4ee8ce

Please sign in to comment.