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

[FIX] Undefined room name in push and e-mail notifications #10318

3 changes: 3 additions & 0 deletions packages/rocketchat-lib/server/lib/roomTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ RocketChat.roomTypes = new class roomTypesServer extends RoomTypesCommon {
return this.roomTypes[roomType] && this.roomTypes[roomType].roomFind;
}

getRoomName(roomType, roomData) {
return this.roomTypes[roomType] && this.roomTypes[roomType].roomName && this.roomTypes[roomType].roomName(roomData);
}

/**
* Run the publish for a room type
Expand Down
2 changes: 1 addition & 1 deletion packages/rocketchat-lib/server/lib/sendEmailOnMessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import s from 'underscore.string';
function getEmailContent({ messageContent, message, user, room }) {
const lng = user && user.language || RocketChat.settings.get('language') || 'en';

const roomName = `#${ RocketChat.settings.get('UI_Allow_room_names_with_special_chars') ? room.fname || room.name : room.name }`;
const roomName = `#${ (RocketChat.settings.get('UI_Allow_room_names_with_special_chars') && room.fname) ? room.fname : RocketChat.roomTypes.getRoomName(room.t, room) }`;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is not needed anymore to test for UI_Allow_room_names_with_special_chars setting here. this test is done on implementations of getRoomName (like this)..


const userName = RocketChat.settings.get('UI_Use_Real_Name') ? message.u.name || message.u.username : message.u.username;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,8 @@ RocketChat.callbacks.add('afterSaveMessage', function(message, room, userId) {

const pushUsernames = {};

const user = RocketChat.models.Users.findOneById(message.u._id);
const user = (room.t !== 'l') ? RocketChat.models.Users.findOneById(message.u._id) : room.v;

// might be a livechat visitor
if (!user) {
return message;
}
Expand Down Expand Up @@ -266,7 +265,7 @@ RocketChat.callbacks.add('afterSaveMessage', function(message, room, userId) {
let push_room = '';
if (RocketChat.settings.get('Push_show_username_room')) {
push_username = user.username;
push_room = `#${ room.name }`;
push_room = `#${ RocketChat.roomTypes.getRoomName(room.t, room) }`;
}

if (room.t == null || room.t === 'd') {
Expand Down