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/utils/server/lib/composeMessageObjectWithUse...

23 lines
761 B

import { Users } from '/app/models';
import { settings } from '/app/settings';
const getUser = (userId) => Users.findOneById(userId);
export const composeMessageObjectWithUser = function(message, userId) {
if (message) {
if (message.starred && Array.isArray(message.starred)) {
message.starred = message.starred.filter((star) => star._id === userId);
}
if (message.u && message.u._id && settings.get('UI_Use_Real_Name')) {
const user = getUser(message.u._id);
message.u.name = user && user.name;
}
if (message.mentions && message.mentions.length && settings.get('UI_Use_Real_Name')) {
message.mentions.forEach((mention) => {
const user = getUser(mention._id);
mention.name = user && user.name;
});
}
}
return message;
};