2018-07-07 01:00:44 +08:00
|
|
|
import { Meteor } from 'meteor/meteor';
|
|
|
|
import { check } from 'meteor/check';
|
|
|
|
import RedisPubSub from '/imports/startup/server/redis';
|
2018-10-24 01:18:09 +08:00
|
|
|
import Breakouts from '/imports/api/breakouts';
|
2018-07-07 01:00:44 +08:00
|
|
|
|
2018-12-28 00:20:03 +08:00
|
|
|
export default function requestJoinURL(credentials, { breakoutId, userId: id }) {
|
2018-07-07 01:00:44 +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);
|
2018-12-28 00:20:03 +08:00
|
|
|
const userId = id || requesterUserId;
|
2018-10-24 01:18:09 +08:00
|
|
|
const Breakout = Breakouts.findOne({ breakoutId });
|
2018-12-28 00:20:03 +08:00
|
|
|
const BreakoutUser = Breakout.users.filter(user => user.userId === userId).shift();
|
|
|
|
|
2018-12-28 19:51:41 +08:00
|
|
|
if (BreakoutUser) return null;
|
2018-07-07 01:00:44 +08:00
|
|
|
const eventName = 'RequestBreakoutJoinURLReqMsg';
|
2018-12-28 00:20:03 +08:00
|
|
|
|
2018-07-07 01:00:44 +08:00
|
|
|
return RedisPubSub.publishUserMessage(
|
|
|
|
CHANNEL, eventName, meetingId, requesterUserId,
|
|
|
|
{
|
|
|
|
meetingId,
|
|
|
|
breakoutId,
|
2018-12-28 00:20:03 +08:00
|
|
|
userId,
|
2018-07-07 01:00:44 +08:00
|
|
|
},
|
|
|
|
);
|
|
|
|
}
|