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

38 lines
1.4 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';
import { check } from 'meteor/check';
2018-10-24 01:18:09 +08:00
export default function createBreakoutRoom(rooms, durationInMinutes, record = false, captureNotes = 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.breakouts.breakoutRoomLimit;
const MIN_BREAKOUT_ROOMS = 2;
const MAX_BREAKOUT_ROOMS = BREAKOUT_LIM > MIN_BREAKOUT_ROOMS ? BREAKOUT_LIM : MIN_BREAKOUT_ROOMS;
2021-05-05 00:25:02 +08:00
const EVENT_NAME = 'CreateBreakoutRoomsCmdMsg';
2018-10-24 01:18:09 +08:00
2021-05-05 00:25:02 +08:00
try {
const { meetingId, requesterUserId } = extractCredentials(this.userId);
2018-10-24 01:18:09 +08:00
2021-05-05 00:25:02 +08:00
check(meetingId, String);
check(requesterUserId, String);
2021-05-05 00:25:02 +08:00
if (rooms.length > MAX_BREAKOUT_ROOMS) {
Logger.info(`Attempt to create breakout rooms with invalid number of rooms in meeting id=${meetingId}`);
return;
}
const payload = {
record,
captureNotes,
2021-05-05 00:25:02 +08:00
durationInMinutes,
rooms,
meetingId,
};
2018-10-24 01:18:09 +08:00
2021-05-05 00:25:02 +08:00
RedisPubSub.publishUserMessage(CHANNEL, EVENT_NAME, meetingId, requesterUserId, payload);
} catch (err) {
Logger.error(`Exception while invoking method createBreakoutRoom ${err.stack}`);
}
2018-10-24 01:18:09 +08:00
}