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/ee/server/startup/maxRoomsPerGuest.ts

21 lines
681 B

import { Meteor } from 'meteor/meteor';
import { Subscriptions } from '@rocket.chat/models';
import { callbacks } from '../../../lib/callbacks';
import { getMaxRoomsPerGuest } from '../../app/license/server/license';
import { i18n } from '../../../server/lib/i18n';
callbacks.add(
'beforeAddedToRoom',
async ({ user }) => {
if (user.roles?.includes('guest')) {
const totalSubscriptions = await Subscriptions.countByUserId(user._id);
if (totalSubscriptions >= getMaxRoomsPerGuest()) {
throw new Meteor.Error('error-max-rooms-per-guest-reached', i18n.t('error-max-rooms-per-guest-reached'));
}
}
},
callbacks.priority.MEDIUM,
'check-max-rooms-per-guest',
);