The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
Rocket.Chat/apps/meteor/server/services/authorization/canReadRoom.ts

24 lines
646 B

import type { RoomAccessValidator } from '@rocket.chat/core-services';
import { Authorization } from '@rocket.chat/core-services';
import { Subscriptions } from '@rocket.chat/models';
import { canAccessRoom } from './canAccessRoom';
export const canReadRoom: RoomAccessValidator = async (...args) => {
if (!(await canAccessRoom(...args))) {
return false;
}
const [room, user] = args;
if (
user?._id &&
room?.t === 'c' &&
!(await Authorization.hasPermission(user._id, 'preview-c-room')) &&
!(await Subscriptions.findOneByRoomIdAndUserId(room?._id, user._id, { projection: { _id: 1 } }))
) {
return false;
}
return true;
};