Skip to content
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 settings to configure what (nickname/channel/group and message) is being sent to third-party when using push notification. #2345

Merged
merged 2 commits into from
Feb 25, 2016
Merged
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions i18n/en.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,8 @@
"Push_gcm_project_number" : "GCM Project Number",
"Push_production" : "Production",
"Push_test_push" : "Test",
"Push_show_message" : "Show message in notification",
"Push_show_username_room" : "Show channel/group/username in notification",
"Quick_Search" : "Quick Search",
"quote" : "quote",
"Recents" : "Recents",
Expand Down
29 changes: 23 additions & 6 deletions packages/rocketchat-lib/server/lib/sendNotificationsOnMessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,21 @@ RocketChat.callbacks.add('afterSaveMessage', function(message, room) {
}
});

//Set variables depending on Push Notification settings
if (RocketChat.settings.get('Push_show_message')) {
push_message = message.msg
} else {
push_message = ' '
}

if (RocketChat.settings.get('Push_show_username_room')) {
push_username = "@" + user.username
push_room = " @ #" + room.name
} else {
push_username = ' '
push_room = ' '
}

if ((room.t == null) || room.t === 'd') {
userOfMentionId = message.rid.replace(message.u._id, '');
userOfMention = RocketChat.models.Users.findOne({
Expand All @@ -112,10 +127,11 @@ RocketChat.callbacks.add('afterSaveMessage', function(message, room) {
if (Push.enabled === true && userOfMention.statusConnection !== 'online') {
Push.send({
from: 'push',
title: "@" + user.username,
text: message.msg,
title: push_username,
text: push_message,
apn: {
text: "@" + user.username + ":\n" + message.msg
// ternary operator
text: push_username + ((push_username != ' ' && push_message != ' ') ? ":\n" : '') + push_message
},
badge: 1,
sound: 'chime',
Expand Down Expand Up @@ -241,10 +257,11 @@ RocketChat.callbacks.add('afterSaveMessage', function(message, room) {
if (Push.enabled === true) {
Push.send({
from: 'push',
title: "@" + user.username + " @ #" + room.name,
text: message.msg,
title: push_username + push_room,
text: push_message,
apn: {
text: "@" + user.username + " @ #" + room.name + ":\n" + message.msg
// ternary operator
text: push_username + push_room + ((push_username != ' ' && push_room != ' ' && push_message != ' ') ? ":\n" : '') + push_message
},
badge: 1,
sound: 'chime',
Expand Down
4 changes: 4 additions & 0 deletions packages/rocketchat-lib/server/startup/settings.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,10 @@ RocketChat.settings.addGroup 'Push', ->
@add 'Push_gcm_api_key', '', { type: 'string' }
@add 'Push_gcm_project_number', '', { type: 'string', public: true }

@section 'Privacy', ->
@add 'Push_show_username_room', true, { type: 'boolean', public: true }
@add 'Push_show_message', true, { type: 'boolean', public: true }


RocketChat.settings.addGroup 'Layout', ->
@add 'Layout_Sidenav_Footer', '<div><a href="https://github.com/RocketChat/Rocket.Chat" class="logo" target="_blank"> <img src="/images/logo/logo.svg?v=3" /></a><div class="github-tagline"><span class="octicon octicon-pencil" style="color: #994C00"></span> with <span class="octicon octicon-heart" style="color: red"></span> on <span class="octicon octicon-mark-github"></span></div></div>', { type: 'string', public: true, i18nDescription: 'Layout_Sidenav_Footer_description' }
Expand Down