mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 08:36:12 +01:00
fix: admins should see public chats
even if they are not in any of the groups
This commit is contained in:
@@ -130,11 +130,13 @@ Messaging.getPublicRooms = async (callerUid, uid) => {
|
|||||||
|
|
||||||
const allRoomIds = await Messaging.getPublicRoomIdsFromSet('chat:rooms:public:order');
|
const allRoomIds = await Messaging.getPublicRoomIdsFromSet('chat:rooms:public:order');
|
||||||
const allRoomData = await Messaging.getRoomsData(allRoomIds);
|
const allRoomData = await Messaging.getRoomsData(allRoomIds);
|
||||||
|
const isAdmin = await privileges.users.isAdministrator(callerUid);
|
||||||
const checks = await Promise.all(
|
const checks = await Promise.all(
|
||||||
allRoomData.map(
|
allRoomData.map(
|
||||||
room => room && (
|
room => room && (
|
||||||
!Array.isArray(room.groups) ||
|
!Array.isArray(room.groups) ||
|
||||||
!room.groups.length ||
|
!room.groups.length ||
|
||||||
|
isAdmin ||
|
||||||
groups.isMemberOfAny(uid, room && room.groups)
|
groups.isMemberOfAny(uid, room && room.groups)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@@ -369,16 +371,21 @@ Messaging.canMessageUser = async (uid, toUid) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
Messaging.canMessageRoom = async (uid, roomId) => {
|
Messaging.canMessageRoom = async (uid, roomId) => {
|
||||||
|
console.log('can message room', uid, roomId);
|
||||||
if (meta.config.disableChat || uid <= 0) {
|
if (meta.config.disableChat || uid <= 0) {
|
||||||
throw new Error('[[error:chat-disabled]]');
|
throw new Error('[[error:chat-disabled]]');
|
||||||
}
|
}
|
||||||
|
|
||||||
const [inRoom, canChat] = await Promise.all([
|
const [roomData, inRoom, canChat] = await Promise.all([
|
||||||
|
Messaging.getRoomData(roomId),
|
||||||
Messaging.isUserInRoom(uid, roomId),
|
Messaging.isUserInRoom(uid, roomId),
|
||||||
privileges.global.can('chat', uid),
|
privileges.global.can('chat', uid),
|
||||||
checkReputation(uid),
|
checkReputation(uid),
|
||||||
]);
|
]);
|
||||||
|
if (!roomData) {
|
||||||
|
throw new Error('[[error:no-room]]');
|
||||||
|
}
|
||||||
|
console.log('can chat', canChat);
|
||||||
if (!inRoom) {
|
if (!inRoom) {
|
||||||
throw new Error('[[error:not-in-room]]');
|
throw new Error('[[error:not-in-room]]');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -454,7 +454,7 @@ module.exports = function (Messaging) {
|
|||||||
if (!room ||
|
if (!room ||
|
||||||
(!room.public && !inRoom) ||
|
(!room.public && !inRoom) ||
|
||||||
(room.public && (
|
(room.public && (
|
||||||
Array.isArray(room.groups) && room.groups.length && !(await groups.isMemberOfAny(uid, room.groups)))
|
Array.isArray(room.groups) && room.groups.length && !isAdmin && !(await groups.isMemberOfAny(uid, room.groups)))
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
Reference in New Issue
Block a user