Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion packages/rocketchat-lib/server/sendMessage.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,14 @@ RocketChat.sendMessage = (user, message, room, options) ->
mentionIds.push mention._id

if mentionIds.length > 0
usersOfMention = Meteor.users.find({_id: {$in: mentionIds}}, {fields: {_id: 1, username: 1}}).fetch()

if mentionIds.indexOf('all') is -1
for usersOfMentionItem in usersOfMention
if room.usernames.indexOf(usersOfMentionItem.username) is -1
Meteor.runAsUser usersOfMentionItem._id, ->
Meteor.call 'joinRoom', room._id

###
Update all other subscriptions of mentioned users to alert their owners and incrementing
the unread counter for mentions and direct messages
Expand Down Expand Up @@ -141,7 +149,6 @@ RocketChat.sendMessage = (user, message, room, options) ->
query._id =
$in: mentionIds

usersOfMention = Meteor.users.find(query, {fields: {_id: 1}}).fetch()
usersOfMentionIds = _.pluck(usersOfMention, '_id');
if usersOfMentionIds.length > 0
Push.send
Expand Down