Skip to content

Commit

Permalink
[FIX] Improve desktop notification formatting (#10445)
Browse files Browse the repository at this point in the history
* Improved notification formatting

* Fixed lint issues

* Changed body format
  • Loading branch information
Sameesunkaria authored and sampaiodiego committed May 8, 2018
1 parent 9bd5de3 commit 13b761c
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions packages/rocketchat-lib/server/lib/sendNotificationsOnMessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,24 @@ function notifyDesktopUser(userId, user, message, room, duration) {
if (UI_Use_Real_Name) {
message.msg = replaceMentionedUsernamesWithFullNames(message.msg, message.mentions);
}
let title = UI_Use_Real_Name ? user.name : `@${ user.username }`;
if (room.t !== 'd' && room.name) {
title += ` @ #${ room.name }`;

let title = '';
let text = '';
if (room.t === 'd') {
title = UI_Use_Real_Name ? user.name : `@${ user.username }`;
text = message.msg;
} else if (room.name) {
title = `#${ room.name }`;
text = `${ user.username }: ${ message.msg }`;
}

if (title === '' || text === '') {
return;
}

RocketChat.Notifications.notifyUser(userId, 'notification', {
title,
text: message.msg,
text,
duration,
payload: {
_id: message._id,
Expand Down

0 comments on commit 13b761c

Please sign in to comment.