mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-28 17:46:16 +01:00
fix: #10006, dont allow new rooms or adding to a room if target is blocked
This commit is contained in:
@@ -146,19 +146,7 @@ SocketModules.chats.addUserToRoom = async function (socket, data) {
|
||||
if (!uid) {
|
||||
throw new Error('[[error:no-user]]');
|
||||
}
|
||||
if (socket.uid === parseInt(uid, 10)) {
|
||||
throw new Error('[[error:cant-chat-with-yourself]]');
|
||||
}
|
||||
const [settings, isAdminOrGlobalMod, isFollowing] = await Promise.all([
|
||||
user.getSettings(uid),
|
||||
user.isAdminOrGlobalMod(socket.uid),
|
||||
user.isFollowing(uid, socket.uid),
|
||||
]);
|
||||
|
||||
if (settings.restrictChat && !isAdminOrGlobalMod && !isFollowing) {
|
||||
throw new Error('[[error:chat-restricted]]');
|
||||
}
|
||||
|
||||
await Messaging.canMessageUser(socket.uid, uid);
|
||||
await Messaging.addUsersToRoom(socket.uid, [uid], data.roomId);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user