-
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
Add fname
to subscriptions in memory
#6597
Changes from all commits
81158ad
03c04e6
fc09333
9f8aa60
a172517
90b5b8b
da06ef2
1ccc23e
fc53636
e6df308
b152621
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,22 @@ | ||
Meteor.startup(function() { | ||
RocketChat.Notifications.onLogged('Users:NameChanged', function({_id, name, username}) { | ||
RocketChat.models.Messages.update({ | ||
'u._id': _id | ||
}, { | ||
$set: { | ||
'u.name': name | ||
} | ||
}, { | ||
multi: true | ||
}); | ||
|
||
RocketChat.models.Subscriptions.update({ | ||
name: username, | ||
t: 'd' | ||
}, { | ||
$set: { | ||
fname: name | ||
} | ||
}); | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,10 +58,16 @@ Meteor.methods({ | |
records = RocketChat.models.Messages.findVisibleByRoomIdNotContainingTypes(rid, hideMessagesOfType, options).fetch(); | ||
} | ||
|
||
const UI_Use_Real_Name = RocketChat.settings.get('UI_Use_Real_Name') === true; | ||
|
||
const messages = records.map((message) => { | ||
message.starred = _.findWhere(message.starred, { | ||
_id: fromId | ||
}); | ||
if (message.u && message.u._id && UI_Use_Real_Name) { | ||
const user = RocketChat.models.Users.findOneById(message.u._id); | ||
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. Isn't this going to make quite a lot of request to the db to get the users 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. Not to the DB, to the memory cache, it's really fast cuz is indexed using a hash map |
||
message.u.name = user && user.name; | ||
} | ||
return message; | ||
}); | ||
|
||
|
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.
Same as my other comment, would it be better to fetch all users in result at once, then map the name on to
message.u.name
?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.
Same answer 😄