-
Notifications
You must be signed in to change notification settings - Fork 11.1k
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
Changes from 22 commits
b30d63b
eec5ea8
29f9ceb
d8a2682
2c1d6e5
b7a6bc8
5377d89
553ab70
9472a6b
1d3c9c9
fed2c79
12e0606
5720b9e
2d0570a
c436466
f7c6cf3
14e388c
51f65d9
bc4200e
409b279
8473f6b
39a6379
557c36b
89e9cc0
a802409
409f964
7cfcc21
e280f58
4040985
f475c01
20a0fc0
c3388d9
c342223
debcf40
cddb810
7299c03
439a9bf
404f758
253f993
7f51161
dad299a
2c44667
1fb0123
3d37581
1050044
429d35c
c9bfdc6
f73c018
ecef03e
113e861
13d0286
1911e57
f6cc3fb
7844083
1dce810
1d7c70e
18fd157
cf6f43b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
RocketChat._setRealName = (userId, name) -> | ||
name = s.trim name | ||
if not userId or not name | ||
return false | ||
|
||
user = RocketChat.models.Users.findOneById userId | ||
|
||
# User already has desired name, return | ||
if user.name is name | ||
return user | ||
|
||
previousName = user.name | ||
|
||
if previousName | ||
RocketChat.models.Messages.updateAllNamesByUserId user._id, name | ||
RocketChat.models.Subscriptions.setRealNameForDirectRoomsWithUsername user.username, name | ||
|
||
# Set new name | ||
RocketChat.models.Users.setName user._id, name | ||
user.name = name | ||
return user | ||
|
||
RocketChat.setRealName = RocketChat.RateLimiter.limitFunction RocketChat._setRealName, 1, 60000, | ||
0: () -> return not Meteor.userId() or not RocketChat.authz.hasPermission(Meteor.userId(), 'edit-other-user-info') # Administrators have permission to change others names, so don't limit those |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,5 +8,13 @@ Template.spotlightTemplate.helpers({ | |
return 'status-' + (Session.get(`user_${this.name}_status`) || 'offline'); | ||
} | ||
return 'status-offline'; | ||
}, | ||
|
||
name() { | ||
if (RocketChat.settings.get('UI_Use_Real_Name') && this.fname) { | ||
return this.fname; | ||
} else { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can reutrn without else. return this.name; There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for reviewing @givisok, I've made the change suggested. |
||
return this.name; | ||
} | ||
} | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,5 +30,6 @@ Meteor.methods | |
u: | ||
_id: fromUser._id | ||
username: fromUser.username | ||
name: fromUser.name | ||
|
||
return true |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.