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';
|
2018-10-24 01:18:09 +08:00
|
|
|
|
2020-02-07 04:47:28 +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;
|
2020-07-30 03:28:15 +08:00
|
|
|
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
|
|
|
|
2020-02-07 04:47:28 +08:00
|
|
|
const { meetingId, requesterUserId } = extractCredentials(this.userId);
|
2018-10-24 01:18:09 +08:00
|
|
|
|
|
|
|
const eventName = 'CreateBreakoutRoomsCmdMsg';
|
2020-07-30 03:28:15 +08:00
|
|
|
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);
|
|
|
|
}
|