Add try/catch on breakouts methods

This commit is contained in:
Joao Siebel 2021-05-04 13:25:02 -03:00
parent 2b21a75007
commit 8bd9d056f2
3 changed files with 47 additions and 33 deletions

View File

@ -10,13 +10,14 @@ export default function createBreakoutRoom(rooms, durationInMinutes, record = fa
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;
const EVENT_NAME = 'CreateBreakoutRoomsCmdMsg';
try {
const { meetingId, requesterUserId } = extractCredentials(this.userId);
check(meetingId, String);
check(requesterUserId, String);
const eventName = 'CreateBreakoutRoomsCmdMsg';
if (rooms.length > MAX_BREAKOUT_ROOMS) {
Logger.info(`Attempt to create breakout rooms with invalid number of rooms in meeting id=${meetingId}`);
return;
@ -28,5 +29,8 @@ export default function createBreakoutRoom(rooms, durationInMinutes, record = fa
meetingId,
};
return RedisPubSub.publishUserMessage(CHANNEL, eventName, meetingId, requesterUserId, payload);
RedisPubSub.publishUserMessage(CHANNEL, EVENT_NAME, meetingId, requesterUserId, payload);
} catch (err) {
Logger.error(`Exception while invoking method createBreakoutRoom ${err.stack}`);
}
}

View File

@ -2,16 +2,21 @@ import { Meteor } from 'meteor/meteor';
import { check } from 'meteor/check';
import RedisPubSub from '/imports/startup/server/redis';
import { extractCredentials } from '/imports/api/common/server/helpers';
import Logger from '/imports/startup/server/logger';
export default function endAllBreakouts() {
const REDIS_CONFIG = Meteor.settings.private.redis;
const CHANNEL = REDIS_CONFIG.channels.toAkkaApps;
const EVENT_NAME = 'EndAllBreakoutRoomsMsg';
try {
const { meetingId, requesterUserId } = extractCredentials(this.userId);
check(meetingId, String);
check(requesterUserId, String);
const eventName = 'EndAllBreakoutRoomsMsg';
return RedisPubSub.publishUserMessage(CHANNEL, eventName, meetingId, requesterUserId, null);
return RedisPubSub.publishUserMessage(CHANNEL, EVENT_NAME, meetingId, requesterUserId, null);
} catch (err) {
Logger.error(`Exception while invoking method endAllBreakouts ${err.stack}`);
}
}

View File

@ -2,25 +2,30 @@ import { Meteor } from 'meteor/meteor';
import RedisPubSub from '/imports/startup/server/redis';
import { extractCredentials } from '/imports/api/common/server/helpers';
import { check } from 'meteor/check';
import Logger from '/imports/startup/server/logger';
export default function requestJoinURL({ breakoutId, userId: userIdToInvite }) {
const REDIS_CONFIG = Meteor.settings.private.redis;
const CHANNEL = REDIS_CONFIG.channels.toAkkaApps;
const EVENT_NAME = 'RequestBreakoutJoinURLReqMsg';
try {
const { meetingId, requesterUserId } = extractCredentials(this.userId);
check(meetingId, String);
check(requesterUserId, String);
const userId = userIdToInvite || requesterUserId;
const eventName = 'RequestBreakoutJoinURLReqMsg';
return RedisPubSub.publishUserMessage(
CHANNEL, eventName, meetingId, requesterUserId,
CHANNEL, EVENT_NAME, meetingId, requesterUserId,
{
meetingId,
breakoutId,
userId,
},
);
} catch (err) {
Logger.error(`Exception while invoking method requestJoinURL ${err.stack}`);
}
}