Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
gabriellsh committed Oct 20, 2023
1 parent ffc70f1 commit 735fa4e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
10 changes: 2 additions & 8 deletions apps/meteor/app/lib/server/functions/processWebhookMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type { IMessage, IUser, RequiredField, MessageAttachment } from '@rocket.
import { Meteor } from 'meteor/meteor';
import _ from 'underscore';

import { ensureArray } from '../../../../lib/utils/arrayUtils';
import { trim } from '../../../../lib/utils/stringUtils';
import { SystemLogger } from '../../../../server/lib/logger/system';
import { validateRoomMessagePermissionsAsync } from '../../../authorization/server/functions/canSendMessage';
Expand Down Expand Up @@ -33,21 +34,14 @@ 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(toArray(messageObj.channel || messageObj.roomId || defaultValues.channel))];
const channels: Array<string> = [...new Set(ensureArray(messageObj.channel || messageObj.roomId || defaultValues.channel))];

for await (const channel of channels) {
const channelType = channel[0];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,17 @@ const ForwardMessageModal = ({ onClose, permalink, message }: ForwardMessageProp
mutationFn: async () => {
const optionalMessage = '';
const curMsg = await prependReplies(optionalMessage, [message]);
const sendPayload = {
roomId: rooms,
text: curMsg,
};

return sendMessage(sendPayload);
return Promise.all(
rooms.map(async (roomId) => {
const sendPayload = {
roomId,
text: curMsg,
};

await sendMessage(sendPayload);
}),
);
},
onSuccess: () => {
dispatchToastMessage({ type: 'success', message: t('Message_has_been_forwarded') });
Expand Down

0 comments on commit 735fa4e

Please sign in to comment.