Skip to content

Commit

Permalink
Fix: Notifications of Group DM were not showing the room name (#17058)
Browse files Browse the repository at this point in the history
* Fix: Notifications of Group DM were not showing the room name

* Use isGroupChat method

* Add sender to notification text

Co-authored-by: Diego Sampaio <chinello@gmail.com>
  • Loading branch information
rodrigok and sampaiodiego authored Mar 28, 2020
1 parent 4127a3c commit 7f7a551
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
13 changes: 10 additions & 3 deletions app/lib/lib/roomTypes/direct.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,17 @@ export class DirectMessageRoomType extends RoomTypeConfig {
return {};
}

const title = settings.get('UI_Use_Real_Name') ? user.name : `@${ user.username }`;
const text = notificationMessage;
if (this.isGroupChat(room)) {
return {
title: this.roomName(room),
text: `${ (settings.get('UI_Use_Real_Name') && user.name) || user.username }: ${ notificationMessage }`,
};
}

return { title, text };
return {
title: (settings.get('UI_Use_Real_Name') && user.name) || user.username,
text: notificationMessage,
};
}

getAvatarPath(roomData, subData) {
Expand Down
8 changes: 5 additions & 3 deletions app/lib/server/functions/notifications/email.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ function getEmailContent({ message, user, room }) {
const roomName = s.escapeHTML(`#${ roomTypes.getRoomName(room.t, room) }`);
const userName = s.escapeHTML(settings.get('UI_Use_Real_Name') ? message.u.name || message.u.username : message.u.username);

const header = TAPi18n.__(room.t === 'd' ? 'User_sent_a_message_to_you' : 'User_sent_a_message_on_channel', {
const roomType = roomTypes.getConfig(room.t);

const header = TAPi18n.__(!roomType.isGroupChat(room) ? 'User_sent_a_message_to_you' : 'User_sent_a_message_on_channel', {
username: userName,
channel: roomName,
lng,
Expand Down Expand Up @@ -54,7 +56,7 @@ function getEmailContent({ message, user, room }) {
}

if (message.file) {
const fileHeader = TAPi18n.__(room.t === 'd' ? 'User_uploaded_a_file_to_you' : 'User_uploaded_a_file_on_channel', {
const fileHeader = TAPi18n.__(!roomType.isGroupChat(room) ? 'User_uploaded_a_file_to_you' : 'User_uploaded_a_file_on_channel', {
username: userName,
channel: roomName,
lng,
Expand Down Expand Up @@ -112,7 +114,7 @@ export function sendEmail({ message, user, subscription, room, emailAddress, has
const username = settings.get('UI_Use_Real_Name') ? message.u.name || message.u.username : message.u.username;
let subjectKey = 'Offline_Mention_All_Email';

if (room.t === 'd') {
if (!roomTypes.getConfig(room.t).isGroupChat(room)) {
subjectKey = 'Offline_DM_Email';
} else if (hasMentionToUser) {
subjectKey = 'Offline_Mention_Email';
Expand Down
2 changes: 1 addition & 1 deletion app/lib/server/functions/notifications/mobile.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export async function sendSinglePush({ room, message, userId, receiverUsername,
messageType: message.t,
messageId: message._id,
},
roomName: settings.get('Push_show_username_room') && room.t !== 'd' ? `#${ roomTypes.getRoomName(room.t, room) }` : '',
roomName: settings.get('Push_show_username_room') && roomTypes.getConfig(room.t).isGroupChat(room) ? `#${ roomTypes.getRoomName(room.t, room) }` : '',
username,
message: settings.get('Push_show_message') ? notificationMessage : ' ',
badge: await getBadgeCount(userId),
Expand Down

0 comments on commit 7f7a551

Please sign in to comment.