diff --git a/i18n/en.i18n.json b/i18n/en.i18n.json index 8d547aebc7ef..1e1104237cf1 100644 --- a/i18n/en.i18n.json +++ b/i18n/en.i18n.json @@ -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", diff --git a/packages/rocketchat-lib/server/lib/sendNotificationsOnMessage.js b/packages/rocketchat-lib/server/lib/sendNotificationsOnMessage.js index ec926e454c03..58c0732cf8ed 100644 --- a/packages/rocketchat-lib/server/lib/sendNotificationsOnMessage.js +++ b/packages/rocketchat-lib/server/lib/sendNotificationsOnMessage.js @@ -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({ @@ -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', @@ -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', diff --git a/packages/rocketchat-lib/server/startup/settings.coffee b/packages/rocketchat-lib/server/startup/settings.coffee index 439becfe4a7c..4d05b4bfff9e 100644 --- a/packages/rocketchat-lib/server/startup/settings.coffee +++ b/packages/rocketchat-lib/server/startup/settings.coffee @@ -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', '
with on
', { type: 'string', public: true, i18nDescription: 'Layout_Sidenav_Footer_description' }