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

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

Merged
merged 58 commits into from Apr 4, 2017

Conversation

alexbrazier
Copy link
Contributor

@alexbrazier alexbrazier commented Jul 23, 2016

@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
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
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
Copy link
Member

rodrigok commented Aug 2, 2016

@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
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
Copy link
Member

rodrigok commented Aug 3, 2016

@alexbrazier I prefer to have the migration.

@alexbrazier
Copy link
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
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?

@@ -95,6 +94,10 @@ const CROWD = class CROWD {
active: crowdUser.active
};

if (crowdUser.displayname) {
RocketChat._setRealName(user._id, crowdUser.displayname);
Copy link
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
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
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
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
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.

@@ -64,8 +64,7 @@ RocketChat.roomTypes.add('d', 20, {
},

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
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
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
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
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
Contributor Author

Choose a reason for hiding this comment

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

Deleted

@@ -23,7 +23,10 @@ Meteor.methods({
};

const map = (record) => {
return record._user.username;
return {
Copy link
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
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
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
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
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
Contributor Author

Choose a reason for hiding this comment

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

Done

@rodrigok
Copy link
Member

rodrigok commented Apr 1, 2017

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
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
Contributor Author

Choose a reason for hiding this comment

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

Done

@@ -11,8 +11,8 @@
{{> avatar username=username}}
</div>
<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
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
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)

@@ -7,7 +7,7 @@
{{> avatar username=username}}
</div>
<div class="data">
<h4>{{username}}</h4>
<h4 data-username="{{username}}">{{fname}}</h4>
Copy link
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
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
Copy link
Member

rodrigok commented Apr 1, 2017

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

Copy link
Contributor Author

@alexbrazier alexbrazier left a comment

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
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.

@@ -95,6 +94,10 @@ const CROWD = class CROWD {
active: crowdUser.active
};

if (crowdUser.displayname) {
RocketChat._setRealName(user._id, crowdUser.displayname);
Copy link
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
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
Contributor Author

Choose a reason for hiding this comment

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

Done

@@ -11,8 +11,8 @@
{{> avatar username=username}}
</div>
<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
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
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
Contributor Author

Choose a reason for hiding this comment

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

Done

@@ -23,7 +23,10 @@ Meteor.methods({
};

const map = (record) => {
return record._user.username;
return {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@@ -64,8 +64,7 @@ RocketChat.roomTypes.add('d', 20, {
},

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
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

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

@danpospisil
Copy link
Contributor

Thanks guys!!!

@alexmsierra
Copy link

Huge thank you. Awaiting this for a long time.

@kushlces
Copy link

Seriously! Massive thanks!!!!!

@pH142857
Copy link

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
Copy link

givisok commented Apr 12, 2018

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

@mddvul22
Copy link

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

@pH142857
Copy link

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