Skip to content

Node.js based forum software built for the modern web

fix: #12923, inability to start chat with remote users via profile

Julian Lamb6a2520fcc8f
diff --git a/public/src/client/account/header.js b/public/src/client/account/header.js
index 9b34fa6fdc..c12c25701f 100644
--- a/public/src/client/account/header.js
+++ b/public/src/client/account/header.js
@@ -32,7 +32,7 @@ define('forum/account/header', [
components.get('account/unfollow').on('click', () => toggleFollow('unfollow'));
components.get('account/chat').on('click', async function () {
- const { roomId } = await api.get(`/users/${ajaxify.data.uid}/chat`);
+ const { roomId } = await api.get(`/users/${encodeURIComponent(ajaxify.data.uid)}/chat`);
const chat = await app.require('chat');
if (roomId) {
chat.openChat(roomId);
diff --git a/public/src/modules/chat.js b/public/src/modules/chat.js
index c48113d2f7..426bd8c6e9 100644
--- a/public/src/modules/chat.js
+++ b/public/src/modules/chat.js
@@ -64,6 +64,11 @@ define('chat', [
return alerts.error('[[error:cant-chat-with-yourself]]');
}
+ // Skip dnd check for remote users
+ if (!utils.isNumber(touid)) {
+ return createChat();
+ }
+
api.get(`/users/${touid}/status`).then(({ status }) => {
if (status !== 'dnd') {
return createChat();
diff --git a/src/messaging/index.js b/src/messaging/index.js
index da6991495a..67b6346856 100644
--- a/src/messaging/index.js
+++ b/src/messaging/index.js
@@ -247,7 +247,9 @@ Messaging.generateUsernames = function (room, excludeUid) {
Messaging.generateChatWithMessage = async function (room, callerUid, userLang) {
const users = room.users.filter(u => u && parseInt(u.uid, 10) !== callerUid);
- const usernames = users.map(u => `<a href="${relative_path}/uid/${u.uid}">${u.username}</a>`);
+ const usernames = users.map(u => (utils.isNumber(u.uid) ?
+ `<a href="${relative_path}/uid/${u.uid}">${u.username}</a>` :
+ `<a href="${relative_path}/user/${u.username}">${u.username}</a>`));
let compiled = '';
if (!users.length) {
return '[[modules:chat.no-users-in-room]]';