Skip to content
Snippets Groups Projects
Commit 03c04e6a authored by Rodrigo Nascimento's avatar Rodrigo Nascimento
Browse files

Send user’s name within message records

parent 81158ad0
No related branches found
No related tags found
No related merge requests found
......@@ -5,7 +5,7 @@ RocketChat.sendMessage = (user, message, room, upsert = false) ->
unless message.ts?
message.ts = new Date()
message.u = _.pick user, ['_id','username', 'name']
message.u = _.pick user, ['_id','username']
if not Match.test(message.msg, String)
message.msg = ''
......
......@@ -51,6 +51,10 @@ Meteor.methods({
const messages = _.map(records, (message) => {
message.starred = _.findWhere(message.starred, { _id: fromUserId });
if (message.u && message.u._id) {
const user = RocketChat.models.Users.findOneById(message.u._id);
message.u.name = user && user.name;
}
return message;
});
......
......@@ -62,6 +62,10 @@ Meteor.methods({
message.starred = _.findWhere(message.starred, {
_id: fromId
});
if (message.u && message.u._id) {
const user = RocketChat.models.Users.findOneById(message.u._id);
message.u.name = user && user.name;
}
return message;
});
......
......@@ -45,6 +45,10 @@ msgStream.allowEmit('__my_messages__', function(eventName, msg, options) {
Meteor.startup(function() {
function publishMessage(type, record) {
if (record._hidden !== true && (record.imported == null)) {
if (record.u && record.u._id) {
const user = RocketChat.models.Users.findOneById(record.u._id);
record.u.name = user && user.name;
}
msgStream.emitWithoutBroadcast('__my_messages__', record, {});
return msgStream.emitWithoutBroadcast(record.rid, record);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment