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

Set alert, open room and increate unread for all users in room if there is a mention for 'all'

parent 8d2f2fe2
No related branches found
No related tags found
No related merge requests found
...@@ -79,12 +79,18 @@ RocketChat.sendMessage = (user, message, room) -> ...@@ -79,12 +79,18 @@ RocketChat.sendMessage = (user, message, room) ->
Update all other subscriptions of mentioned users to alert their owners and incrementing Update all other subscriptions of mentioned users to alert their owners and incrementing
the unread counter for mentions and direct messages the unread counter for mentions and direct messages
### ###
ChatSubscription.update query =
# only subscriptions to the same room # only subscriptions to the same room
rid: message.rid rid: message.rid
# the mentioned user
'u._id': mention._id if mention._id is 'all'
, # all users except sender if mention is for all
query['u._id'] = $ne: user._id
else
# the mentioned user if mention isn't for all
query['u._id'] = mention._id
ChatSubscription.update query,
$set: $set:
# alert de user # alert de user
alert: true alert: true
...@@ -93,6 +99,8 @@ RocketChat.sendMessage = (user, message, room) -> ...@@ -93,6 +99,8 @@ RocketChat.sendMessage = (user, message, room) ->
# increment unread couter # increment unread couter
$inc: $inc:
unread: 1 unread: 1
,
multi: true
### ###
Update all other subscriptions to alert their owners but witout incrementing Update all other subscriptions to alert their owners but witout incrementing
......
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