2018-10-24 01:18:09 +08:00
|
|
|
import { Meteor } from 'meteor/meteor';
|
|
|
|
import RedisPubSub from '/imports/startup/server/redis';
|
2019-06-14 21:54:59 +08:00
|
|
|
import Logger from '/imports/startup/server/logger';
|
2020-02-07 04:47:28 +08:00
|
|
|
import { extractCredentials } from '/imports/api/common/server/helpers';
|
2021-03-17 00:15:41 +08:00
|
|
|
import { check } from 'meteor/check';
|
2018-10-24 01:18:09 +08:00
|
|
|
|
2022-09-20 23:43:13 +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;
|
2021-02-09 01:40:03 +08:00
|
|
|
const BREAKOUT_LIM = Meteor.settings.public.app.breakouts.breakoutRoomLimit;
|
2020-07-30 03:28:15 +08:00
|
|
|
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-03-17 00:15:41 +08:00
|
|
|
|
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,
|
2022-09-20 23:43:13 +08:00
|
|
|
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
|
|
|
}
|