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/apps/meteor/app/api/server/helpers/composeRoomWithLastMessage.ts

12 lines
395 B

import type { IRoom } from '@rocket.chat/core-typings';
import { normalizeMessagesForUser } from '../../../utils/server/lib/normalizeMessagesForUser';
Convert rocketchat-api to main module structure (#12510) * First wave of removal of Meteor global * Second wave of removal of Meteor global * Third wave of removal of Meteor global * Fix tests * Remove global variable SHA256 * Remove global variable WebApp * Remove global variable EJSON * Remove global variable Email * Remove global variable HTTP * Remove global variable Random * Remove global variable ReactiveDict * Remove global variable ReactiveVar * Remove global variable Accounts * Remove globals variables Match and check * Remove global variable Mongo * Remove global variable moment * Remove global variable Tracker * Remove global variable Blaze * Remove global variables FlowRouter and BlazeLayout * Add FlowRouter to eslint global in tests file * Remove global variable DDPRateLimiter * Remove global variable Session * Remove global variable UAParser * Remove global variable Promise * Remove global variable Reload * Remove global variable CryptoJS * Remove global variable Template * Remove global variable TAPi18n * Remove global variable TAPi18next * Exposing t function from rocketchat:ui package * Convert chatpal search to main module structure * Fix ESLint * Convert meteor-accounts-saml to main module structure * Convert meteor-autocomplete to main module structure * Convert meteor-timesync package to modular structure * exposing modal global variable * Convert rocketchat-2fa to main module structure * Change exposing of fireGlobalEvent function from window to package * Moved handleError function from client to rocketchat:lib package * Convert rocketchat:action-linsk package to main module structure * make ChatRoom exportable by package * Convert rocketchat-analytics to main module structure * disable eslint no-undef in fireGlobalEvent * Export processwebhookMessage from integrations package * Convert rocketchat-api to main module structure
7 years ago
export async function composeRoomWithLastMessage(room: IRoom, userId: string) {
if (room.lastMessage) {
const [lastMessage] = await normalizeMessagesForUser([room.lastMessage], userId);
room.lastMessage = lastMessage;
}
return room;
}