bigbluebutton-Github/bigbluebutton-html5/imports/api/breakouts/server/methods/createBreakout.js

26 lines
1.1 KiB
JavaScript
Raw Normal View History

2018-10-24 01:18:09 +08:00
import { Meteor } from 'meteor/meteor';
import RedisPubSub from '/imports/startup/server/redis';
import Logger from '/imports/startup/server/logger';
import { extractCredentials } from '/imports/api/common/server/helpers';
2018-10-24 01:18:09 +08:00
export default function createBreakoutRoom(rooms, durationInMinutes, record = false) {
2018-10-24 01:18:09 +08:00
const REDIS_CONFIG = Meteor.settings.private.redis;
const CHANNEL = REDIS_CONFIG.channels.toAkkaApps;
const BREAKOUT_LIM = Meteor.settings.public.app.breakoutRoomLimit;
const MIN_BREAKOUT_ROOMS = 2;
const MAX_BREAKOUT_ROOMS = BREAKOUT_LIM > MIN_BREAKOUT_ROOMS ? BREAKOUT_LIM : MIN_BREAKOUT_ROOMS;
2018-10-24 01:18:09 +08:00
const { meetingId, requesterUserId } = extractCredentials(this.userId);
2018-10-24 01:18:09 +08:00
const eventName = 'CreateBreakoutRoomsCmdMsg';
if (rooms.length > MAX_BREAKOUT_ROOMS) return Logger.info(`Attempt to create breakout rooms with invalid number of rooms in meeting id=${meetingId}`);
2018-10-24 01:18:09 +08:00
const payload = {
record,
durationInMinutes,
rooms,
meetingId,
};
return RedisPubSub.publishUserMessage(CHANNEL, eventName, meetingId, requesterUserId, payload);
}