Skip to content

Commit

Permalink
Improvement to push notifications on direct messages (#10788)
Browse files Browse the repository at this point in the history
  • Loading branch information
sampaiodiego authored and rodrigok committed May 16, 2018
1 parent ae67d4d commit 474fbff
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
11 changes: 8 additions & 3 deletions packages/rocketchat-lib/server/functions/notifications/mobile.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,12 @@ function canSendMessageToRoom(room, username) {
return !((room.muted || []).includes(username));
}

export async function sendSinglePush({ room, message, userId, receiverUsername, senderUsername, notificationMessage }) {
export async function sendSinglePush({ room, message, userId, receiverUsername, senderUsername, senderName, notificationMessage }) {
let username = '';
if (RocketChat.settings.get('Push_show_username_room')) {
username = RocketChat.settings.get('UI_Use_Real_Name') === true ? senderName : senderUsername;
}

RocketChat.PushNotification.send({
roomId: message.rid,
payload: {
Expand All @@ -40,8 +45,8 @@ export async function sendSinglePush({ room, message, userId, receiverUsername,
type: room.t,
name: room.name
},
roomName: RocketChat.settings.get('Push_show_username_room') ? `${ room.t === 'd' ? '' : '#' }${ RocketChat.roomTypes.getRoomName(room.t, room) }` : '',
username: RocketChat.settings.get('Push_show_username_room') ? senderUsername : '',
roomName: RocketChat.settings.get('Push_show_username_room') && room.t !== 'd' ? `#${ RocketChat.roomTypes.getRoomName(room.t, room) }` : '',
username,
message: RocketChat.settings.get('Push_show_message') ? notificationMessage : ' ',
badge: await getBadgeCount(userId),
usersTo: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ const sendNotification = ({
message,
userId: subscription.u._id,
senderUsername: sender.username,
senderName: sender.name,
receiverUsername: receiver.username
});
}
Expand Down

0 comments on commit 474fbff

Please sign in to comment.