Skip to content

Node.js based forum software built for the modern web

fix: chat page browser title

Barış Soner Uşaklı77075c22b5b0
diff --git a/src/messaging/index.js b/src/messaging/index.js
index 76c6030e91..d95dd09a31 100644
--- a/src/messaging/index.js
+++ b/src/messaging/index.js
@@ -172,7 +172,7 @@ Messaging.getPublicRooms = async (callerUid, uid) => {
async function getUsers(roomIds, exceptUid) {
const arrayOfUids = await Promise.all(
- roomIds.map(roomId => Messaging.getUidsInRoom(roomId, 0, 9))
+ roomIds.map(roomId => Messaging.getUidsInRoomFromSet(`chat:room:${roomId}:uids:online`, 0, 9, true))
);
const uniqUids = _.uniq(_.flatten(arrayOfUids)).filter(
_uid => _uid && parseInt(_uid, 10) !== parseInt(exceptUid, 10)
@@ -278,11 +278,12 @@ async function modifyChatRooms(uid, results) {
Messaging.generateUsernames = function (room, excludeUid) {
const users = room.users.filter(u => u && parseInt(u.uid, 10) !== excludeUid);
- const usernames = users.map(u => tx.escape(u.displayname));
+ const usernames = users.map(u => u.displayname);
if (users.length > 3) {
return tx.compile(
'modules:chat.usernames-and-x-others',
- ...[usernames.slice(0, 2), room.userCount - 2]
+ usernames.slice(0, 2).map(tx.escape).join(', '),
+ room.userCount - 2
);
}
return usernames.join(', ');
diff --git a/src/messaging/rooms.js b/src/messaging/rooms.js
index e3ea12c508..ccf1250e7a 100644
--- a/src/messaging/rooms.js
+++ b/src/messaging/rooms.js
@@ -565,7 +565,8 @@ module.exports = function (Messaging) {
users.forEach((user) => {
if (user) {
- user.online = parseInt(user.uid, 10) === parseInt(uid, 10) || onlineUids.includes(String(user.uid));
+ const userUid = String(user.uid);
+ user.online = userUid === String(uid) || onlineUids.includes(userUid);
}
});
diff --git a/src/socket.io/index.js b/src/socket.io/index.js
index f1b062bdb2..e407524629 100644
--- a/src/socket.io/index.js
+++ b/src/socket.io/index.js
@@ -84,7 +84,7 @@ Sockets.init = async function (server) {
function onConnection(socket) {
socket.uid = socket.request.uid;
- socket.data.uid = socket.uid; // socket.data is shared between nodes via fetchSockets
+ socket.data.uid = String(socket.uid); // socket.data is shared between nodes via fetchSockets
socket.ip = (
socket.request.headers['x-forwarded-for'] ||
socket.request.connection.remoteAddress || ''
diff --git a/src/views/partials/chats/recent_room.tpl b/src/views/partials/chats/recent_room.tpl
index 17c96ee2a9..82192f2581 100644
--- a/src/views/partials/chats/recent_room.tpl
+++ b/src/views/partials/chats/recent_room.tpl
@@ -27,8 +27,12 @@
{{{ if !./lastUser.uid }}}
[[modules:chat.no-users-in-room]]
{{{ else }}}
+ {{{ if greaterthan(./users.length, "3") }}}
{{tx(./usernames)}}
- {{{ end }}}
+ {{{ else }}}
+ {./usernames}
+ {{{ end }}}
+ {{{ end }}}
{{{ end }}}
</div>
<!-- IMPORT partials/chats/room-teaser.tpl -->