2018-10-24 01:18:09 +08:00
|
|
|
import { Meteor } from 'meteor/meteor';
|
|
|
|
import { check } from 'meteor/check';
|
|
|
|
import RedisPubSub from '/imports/startup/server/redis';
|
2019-06-14 21:54:59 +08:00
|
|
|
import Logger from '/imports/startup/server/logger';
|
2018-10-24 01:18:09 +08:00
|
|
|
|
2018-10-30 03:29:45 +08:00
|
|
|
export default function createBreakoutRoom(credentials, 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 {
|
|
|
|
meetingId,
|
|
|
|
requesterUserId,
|
|
|
|
requesterToken,
|
|
|
|
} = credentials;
|
|
|
|
|
|
|
|
check(meetingId, String);
|
|
|
|
check(requesterUserId, String);
|
|
|
|
check(requesterToken, String);
|
|
|
|
|
|
|
|
const eventName = 'CreateBreakoutRoomsCmdMsg';
|
2019-06-14 21:54:59 +08:00
|
|
|
if (rooms.length > 8) 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);
|
|
|
|
}
|