Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
Rocket.Chat
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
RocketChat
Rocket.Chat
Commits
069bda70
Commit
069bda70
authored
9 years ago
by
Rodrigo Nascimento
Browse files
Options
Downloads
Patches
Plain Diff
Send push notification for mentions
parent
34103cbd
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
packages/rocketchat-lib/server/sendMessage.coffee
+36
-2
36 additions, 2 deletions
packages/rocketchat-lib/server/sendMessage.coffee
with
36 additions
and
2 deletions
packages/rocketchat-lib/server/sendMessage.coffee
+
36
−
2
View file @
069bda70
...
...
@@ -89,7 +89,11 @@ RocketChat.sendMessage = (user, message, room) ->
userId
:
userOfMention
.
_id
else
mentionIds
=
[]
message
.
mentions
?
.
forEach
(
mention
)
->
mentionIds
.
push
mention
.
_id
if
mentionIds
.
length
>
0
###
Update all other subscriptions of mentioned users to alert their owners and incrementing
the unread counter for mentions and direct messages
...
...
@@ -98,12 +102,12 @@ RocketChat.sendMessage = (user, message, room) ->
# only subscriptions to the same room
rid
:
message
.
rid
if
mention
.
_id
is
'all'
if
mention
Ids
.
indexOf
(
'all'
)
>
-
1
# 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
query
[
'u._id'
]
=
$in
:
mention
Ids
ChatSubscription
.
update
query
,
$set
:
...
...
@@ -117,6 +121,36 @@ RocketChat.sendMessage = (user, message, room) ->
,
multi
:
true
if
Push
.
enabled
is
true
query
=
statusConnection
:
{
$ne
:
'online'
}
if
mentionIds
.
indexOf
(
'all'
)
>
-
1
if
room
.
usernames
?
.
length
>
0
query
.
username
=
$in
:
room
.
usernames
else
query
.
username
=
$in
:
[]
else
query
.
_id
=
$in
:
mentionIds
usersOfMention
=
Meteor
.
users
.
find
(
query
,
{
fields
:
{
username
:
1
}}).
fetch
()
if
usersOfMention
.
length
>
0
for
userOfMention
in
usersOfMention
Push
.
send
from
:
'push'
title
:
userOfMention
.
username
text
:
message
.
msg
badge
:
1
sound
:
'chime'
payload
:
rid
:
message
.
rid
sender
:
message
.
u
query
:
userId
:
userOfMention
.
_id
###
Update all other subscriptions to alert their owners but witout incrementing
the unread counter, as it is only for mentions and direct messages
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment