Skip to content

Use real name instead of username for messages and direct messages list - #3851

Merged
engelgabriel merged 58 commits into
RocketChat:developfrom
alexbrazier:feature/display-name
Apr 4, 2017
Merged

engelgabriel merged 58 commits into
RocketChat:developfrom
alexbrazier:feature/display-name

Conversation

@alexbrazier

@alexbrazier alexbrazier commented Jul 23, 2016 •

Copy link
Copy Markdown
Contributor

@RocketChat/core

Closes #1209
Closes #3453
Closes #3649

Use real name in most places, instead of username

  • Restore @ icon
  • Update messages when user changes name
  • Setting to turn on and off
  • Database migration

Changes

  • Change direct message list to use full name
  • Change messages in channels to show full name
  • Change members list to show full name
  • Change mention so it also searches for full name
  • Admin setting to turn on and off

image

image

image

@graywolf336

Copy link
Copy Markdown
Contributor

I can not speak for the rest of the team, but I believe the direct message icon should stay an ampersand sign @. Also, some installations of Rocket.Chat would prefer that the name is not used and would rather have the usernames (such as gaming servers), so an option to turn this on and off is preferred. Last but not least, what are the performances consequences for this, if any?

@alexbrazier

Copy link
Copy Markdown
Contributor Author

@graywolf336: I think I actually agree with you about the @ sign, I don't think the dot looks right.

I think I will add an option to turn this on and off, as it is quite a big change, and as you say, not everyone will want it.

In terms of performance, there is no impact on speed, there is a small storage impact, as the username as well as the name is stored within the user object for messages. I feel that this impact is relatively small, and I opted for this rather than a speed impact (i.e. making more mongo queries). This also appears to be the technique recommended by mongodb, which is to store the data as you are going to use it, rather than make more requests.

@rodrigok

rodrigok commented Aug 2, 2016

Copy link
Copy Markdown
Member

@alexbrazier if you move back to @, add an option to select if users want to see usernames or names and update all messages when users change their names I will be happy to merge this PR 😄

@alexbrazier

Copy link
Copy Markdown
Contributor Author

@rodrigok I will try to make those changes in the next few days. One of the tasks I set was to create a database migration to add the name to the database for old messages ... should I still do that, or do you think it is ok for old messages to show the username and the new ones to show the full name?

@rodrigok

rodrigok commented Aug 3, 2016

Copy link
Copy Markdown
Member

@alexbrazier I prefer to have the migration.

@alexbrazier

Copy link
Copy Markdown
Contributor Author

@rodrigok I might need some help with the migration. I need to update all messages to add the name field to the user object, and I need to update the subscriptions for direct messages and set the other users name as the fname.

To do this we need to request all users and make the updates. I imagine this would be quite a lot of info to request all at once so it would have to be limited.
Is there a Meteor way to go about this, or a way it has been done before?

@alexbrazier

Copy link
Copy Markdown
Contributor Author

I think this is done, except for the migration. @rodrigok Could I get some input on the database migration as for a large server it will have to get all the user full names and usernames and add them to the messages. Is there a good way of doing this?

};

if (crowdUser.displayname) {
RocketChat._setRealName(user._id, crowdUser.displayname);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

user._id is not defined right?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to id which is defined in the function params

@@ -0,0 +1,24 @@
RocketChat._setRealName = (userId, name) ->

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we convert to JS?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And, why not inside the user's model?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's how setUsername is done, so I just copied that. I think its because it has to make more requests to other models, so it's not self contained within one model.

roomName(roomData) {
const room = ChatSubscription.findOne({ rid: roomData._id }, { fields: { name: 1 } });
return room && room.name;
return ChatSubscription.findOne({ rid: roomData._id }, { fields: { name: 1, fname: 1 } });

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens when room is undefined?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

roomData or the returned result of ChatSubscription? Is there a case where it might be undefined?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably will not happen

@@ -0,0 +1,170 @@
Template.membersList.helpers

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file was converted to JS, can you delete?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deleted


const map = (record) => {
return record._user.username;
return {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an API change, can you describe on HISTORY.md that will change from an array of strings to an array of objects?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -0,0 +1,72 @@
Template.accountBox.helpers

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file was converted, can you delete?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -0,0 +1,125 @@
Template.chatRoomItem.helpers

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file was converted, can you delete?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@rodrigok

rodrigok commented Apr 1, 2017

Copy link
Copy Markdown
Member

What about users without name? We have more than 500 users without name in our demo.

Almost all came from linkedin OAuth, we need to fix that

},
displayName() {
if (RocketChat.settings.get('UI_Use_Real_Name')) {
return this.user.name;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fallback to username if name doesn't exist

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

<div class="info">
<h3 title="{{username}}"><i class="status-{{status}}"></i> {{username}}</h3>
<p class="secondary-font-color">{{name}}</p>
<h3 title="{{name}}"><i class="status-{{status}}"></i> {{name}}</h3>

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Handle case where no name

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Handled in js (if no name then returns Unnamed)

</div>
<div class="data">
<h4>{{username}}</h4>
<h4 data-username="{{username}}">{{fname}}</h4>

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Handle case when no name set

@alexbrazier

Copy link
Copy Markdown
Contributor Author

@rodrigok Thanks for reviewing.

I didn't realise that you could register without a name. As it is currently I think it would just set the name field in the messages to undefined, and in most cases it will fallback to using the username, but I have left a couple of comments where this needs to be fixed.

@rodrigok

rodrigok commented Apr 1, 2017

Copy link
Copy Markdown
Member

@alexbrazier In this particular case it's a bug, but you can turn off the name requirement for registration.

@alexbrazier alexbrazier left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rodrigok I have made the changes requested. Is there anything else that needs to be done?

@@ -0,0 +1,24 @@
RocketChat._setRealName = (userId, name) ->

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's how setUsername is done, so I just copied that. I think its because it has to make more requests to other models, so it's not self contained within one model.

};

if (crowdUser.displayname) {
RocketChat._setRealName(user._id, crowdUser.displayname);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to id which is defined in the function params

@@ -0,0 +1,170 @@
Template.membersList.helpers

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deleted

},
displayName() {
if (RocketChat.settings.get('UI_Use_Real_Name')) {
return this.user.name;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

<div class="info">
<h3 title="{{username}}"><i class="status-{{status}}"></i> {{username}}</h3>
<p class="secondary-font-color">{{name}}</p>
<h3 title="{{name}}"><i class="status-{{status}}"></i> {{name}}</h3>

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Handled in js (if no name then returns Unnamed)

@@ -0,0 +1,72 @@
Template.accountBox.helpers

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -0,0 +1,125 @@
Template.chatRoomItem.helpers

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


const map = (record) => {
return record._user.username;
return {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

roomName(roomData) {
const room = ChatSubscription.findOne({ rid: roomData._id }, { fields: { name: 1 } });
return room && room.name;
return ChatSubscription.findOne({ rid: roomData._id }, { fields: { name: 1, fname: 1 } });

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

roomData or the returned result of ChatSubscription? Is there a case where it might be undefined?

@rodrigok rodrigok modified the milestones: 0.55.0, Short-term Apr 3, 2017
@engelgabriel
engelgabriel merged commit 890c4a2 into RocketChat:develop Apr 4, 2017
@subesokun

Copy link
Copy Markdown

Awesome, thanks a lot! Looking very much forward for this feature to be shipped :) @alexbrazier, great job!

@danpospisil

Copy link
Copy Markdown
Contributor

Thanks guys!!!

@alexmsierra

Copy link
Copy Markdown

Huge thank you. Awaiting this for a long time.

@kushlces

Copy link
Copy Markdown

Seriously! Massive thanks!!!!!

@pH142857

Copy link
Copy Markdown

Hi, I'm new to the Github interface but I can see that the last action on this PR was a year ago, yet it is still marked as "ready to be merged" in the labels and I still don't see names displayed in the conversations and lists on Rocket Chat (only usernames). Anyone cares to tell me what's going on?

@givisok

givisok commented Apr 12, 2018

Copy link
Copy Markdown

@pH142857 Hi. Usernames shows in conversation. That pull request was already merged.

@mddvul22

Copy link
Copy Markdown

@pH142857 Have you set "Use Real Name" to "True" in the "User Interface" section of the Layout Admin settings?

@pH142857

Copy link
Copy Markdown

Oh I thought it was supposed to be the default behaviour, and I also thought there would be another label than "ready to be merge" to signify the merge. I checked the option and it now works, thanks to both of you, that was quick ! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Display Name rather than Username while chatting. Emphasize showing realname in UX Ability to have "Display Name" which is different from username.