Skip to content
Snippets Groups Projects
Commit 9753c716 authored by Alex Brazier's avatar Alex Brazier
Browse files

Use cache for mention real names

parent 9f5fa8d4
No related merge requests found
......@@ -57,6 +57,12 @@ Meteor.methods({
const user = RocketChat.models.Users.findOneById(message.u._id);
message.u.name = user && user.name;
}
if (message.mentions && message.mentions.length && UI_Use_Real_Name) {
message.mentions.forEach((mention) => {
const user = RocketChat.models.Users.findOneById(mention._id);
mention.name = user && user.name;
});
}
return message;
});
......
......@@ -26,7 +26,7 @@ function MentionsServer(message) {
username: mention
});
});
mentions = userMentions.length ? Meteor.users.find({ username: {$in: _.unique(userMentions)}}, { fields: {_id: true, username: true, name: true }}).fetch() : [];
mentions = userMentions.length ? Meteor.users.find({ username: {$in: _.unique(userMentions)}}, { fields: {_id: true, username: true}}).fetch() : [];
const verifiedMentions = [...mentionsAll, ...mentions];
if (verifiedMentions.length !== 0) {
......
......@@ -68,6 +68,12 @@ Meteor.methods({
const user = RocketChat.models.Users.findOneById(message.u._id);
message.u.name = user && user.name;
}
if (message.mentions && message.mentions.length && UI_Use_Real_Name) {
message.mentions.forEach((mention) => {
const user = RocketChat.models.Users.findOneById(mention._id);
mention.name = user && user.name;
});
}
return message;
});
......
......@@ -51,6 +51,13 @@ Meteor.startup(function() {
const user = RocketChat.models.Users.findOneById(record.u._id);
record.u.name = user && user.name;
}
if (record.mentions && record.mentions.length && UI_Use_Real_Name) {
record.mentions.forEach((mention) => {
const user = RocketChat.models.Users.findOneById(mention._id);
mention.name = user && user.name;
});
}
msgStream.emitWithoutBroadcast('__my_messages__', record, {});
return msgStream.emitWithoutBroadcast(record.rid, record);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment