99 isOmnichannelRoom ,
1010 isRoomWithJoinCode ,
1111} from '@rocket.chat/core-typings' ;
12+ import { isUserNativeFederated } from '@rocket.chat/core-typings' ;
1213import { Rooms , Subscriptions , Users } from '@rocket.chat/models' ;
1314
1415import { getNameForDMs } from './getNameForDMs' ;
@@ -148,7 +149,7 @@ export class RoomService extends ServiceClassInternal implements IRoomService {
148149 /**
149150 * Method called by users to join a room.
150151 */
151- async join ( { room, user, joinCode } : { room : IRoom ; user : Pick < IUser , '_id' > ; joinCode ?: string } ) {
152+ async join ( { room, user, joinCode } : { room : IRoom ; user : Pick < IUser , '_id' | 'federated' | 'federation' > ; joinCode ?: string } ) {
152153 if ( ! ( await roomCoordinator . getRoomDirectives ( room . t ) ?. allowMemberAction ( room , RoomMemberActions . JOIN , user . _id ) ) ) {
153154 throw new MeteorError ( 'error-not-allowed' , 'Not allowed' , { method : 'joinRoom' } ) ;
154155 }
@@ -161,7 +162,11 @@ export class RoomService extends ServiceClassInternal implements IRoomService {
161162 throw new MeteorError ( 'error-not-allowed' , 'Not allowed' , { method : 'joinRoom' } ) ;
162163 }
163164
164- if ( FederationActions . shouldPerformFederationAction ( room ) && ! ( await Authorization . hasPermission ( user . _id , 'access-federation' ) ) ) {
165+ if (
166+ FederationActions . shouldPerformFederationAction ( room ) &&
167+ ! isUserNativeFederated ( user ) &&
168+ ! ( await Authorization . hasPermission ( user . _id , 'access-federation' ) )
169+ ) {
165170 throw new MeteorError ( 'error-not-authorized-federation' , 'Not authorized to access federation' , { method : 'joinRoom' } ) ;
166171 }
167172
0 commit comments