The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
Rocket.Chat/app/lib/server/functions/attachMessage.ts

34 lines
912 B

import { getUserAvatarURL } from '../../../utils/lib/getUserAvatarURL';
import { roomCoordinator } from '../../../../server/lib/rooms/roomCoordinator';
import { IMessage } from '../../../../definition/IMessage';
import { IRoom } from '../../../../definition/IRoom';
import { MessageAttachment } from '../../../../definition/IMessage/MessageAttachment/MessageAttachment';
export const attachMessage = function (
message: IMessage,
room: IRoom,
): {
text: string;
authorName?: string;
authorIcon: string;
message_link: string;
attachments?: MessageAttachment[];
ts: Date;
} {
const {
msg,
u: { username },
ts,
attachments,
_id,
} = message;
return {
text: msg,
authorName: username,
authorIcon: getUserAvatarURL(username),
// eslint-disable-next-line @typescript-eslint/camelcase
message_link: `${roomCoordinator.getRouteLink(room.t, room)}?msg=${_id}`,
attachments,
ts,
};
};