Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NEW] Show full name in mentions if use full name setting enabled #6690

Merged
merged 7 commits into from
May 31, 2017
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions packages/rocketchat-lib/server/methods/getChannelHistory.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});

Expand Down
6 changes: 4 additions & 2 deletions packages/rocketchat-mentions/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@ function MentionsClient(message) {
if (['all', 'here'].includes(username)) {
return match.replace(mention, `<a class="mention-link mention-link-me mention-link-all background-attention-color">${ mention }</a>`);
}
if (message.temp == null && _.findWhere(message.mentions, {username}) == null) {
const mentionObj = _.findWhere(message.mentions, {username});
if (message.temp == null && mentionObj == null) {
return match;
}
return match.replace(mention, `<a class="mention-link ${ username === me ? 'mention-link-me background-primary-action-color':'' }" data-username="${ username }">${ mention }</a>`);
const name = RocketChat.settings.get('UI_Use_Real_Name') && mentionObj && mentionObj.name;
return match.replace(mention, `<a class="mention-link ${ username === me ? 'mention-link-me background-primary-action-color':'' }" data-username="${ username }" title="${ name ? username : '' }">${ name || mention }</a>`);
});

const msgChannelRegex = new RegExp(`(?:^|\\s|\\n)(#(${ RocketChat.settings.get('UTF8_Names_Validation') }))[:.,\s]?`, 'g');
Expand Down
6 changes: 6 additions & 0 deletions server/methods/loadHistory.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});

Expand Down
7 changes: 7 additions & 0 deletions server/stream/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down