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

This commit is contained in:
Julian Lam
2024-11-19 14:39:35 -05:00
parent 832e8d39af
commit b6a2520fcc
3 changed files with 9 additions and 2 deletions

View File

@@ -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);

View File

@@ -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();

View File

@@ -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]]';