fix: #10006, dont allow new rooms or adding to a room if target is blocked

This commit is contained in:
Barış Soner Uşaklı
2021-11-16 11:57:00 -05:00
parent c16dad40cf
commit 047f031dd7
2 changed files with 15 additions and 24 deletions

View File

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