2018-10-24 01:18:09 +08:00
|
|
|
import Breakouts from '/imports/api/breakouts';
|
|
|
|
import Meetings from '/imports/api/meetings';
|
|
|
|
import { makeCall } from '/imports/ui/services/api';
|
|
|
|
import Auth from '/imports/ui/services/auth';
|
2018-10-26 23:16:29 +08:00
|
|
|
import { Session } from 'meteor/session';
|
2018-10-24 01:18:09 +08:00
|
|
|
import Users from '/imports/api/users';
|
|
|
|
import mapUser from '/imports/ui/services/user/mapUser';
|
|
|
|
|
2018-10-30 03:36:45 +08:00
|
|
|
const findBreakouts = () => {
|
2018-11-02 01:55:35 +08:00
|
|
|
const BreakoutRooms = Breakouts.find({
|
|
|
|
parentMeetingId: Auth.meetingID,
|
|
|
|
}, {
|
|
|
|
sort: {
|
|
|
|
sequence: 1,
|
|
|
|
},
|
|
|
|
}).fetch();
|
2018-10-24 01:18:09 +08:00
|
|
|
|
|
|
|
return BreakoutRooms;
|
|
|
|
};
|
|
|
|
|
|
|
|
const breakoutRoomUser = (breakoutId) => {
|
2018-10-30 03:36:45 +08:00
|
|
|
const breakoutRooms = findBreakouts();
|
2018-10-24 01:18:09 +08:00
|
|
|
const breakoutRoom = breakoutRooms.filter(breakout => breakout.breakoutId === breakoutId).shift();
|
|
|
|
const breakoutUser = breakoutRoom.users.filter(user => user.userId === Auth.userID).shift();
|
|
|
|
return breakoutUser;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const endAllBreakouts = () => {
|
|
|
|
makeCall('endAllBreakouts');
|
|
|
|
};
|
|
|
|
|
|
|
|
const requestJoinURL = (breakoutId) => {
|
|
|
|
makeCall('requestJoinURL', {
|
|
|
|
breakoutId,
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
const transferUserToMeeting = (fromMeetingId, toMeetingId) => makeCall('transferUser', fromMeetingId, toMeetingId);
|
|
|
|
|
2018-11-05 20:27:56 +08:00
|
|
|
const transferToBreakout = (breakoutId) => {
|
2018-10-30 03:36:45 +08:00
|
|
|
const breakoutRooms = findBreakouts();
|
2018-10-24 01:18:09 +08:00
|
|
|
const breakoutRoom = breakoutRooms.filter(breakout => breakout.breakoutId === breakoutId).shift();
|
|
|
|
const breakoutMeeting = Meetings.findOne({
|
|
|
|
$and: [
|
|
|
|
{ 'breakoutProps.sequence': breakoutRoom.sequence },
|
|
|
|
{ 'breakoutProps.parentId': breakoutRoom.parentMeetingId },
|
|
|
|
{ 'meetingProp.isBreakout': true },
|
|
|
|
],
|
|
|
|
});
|
2018-11-05 20:27:56 +08:00
|
|
|
transferUserToMeeting(Auth.meetingID, breakoutMeeting.meetingId);
|
2018-10-24 01:18:09 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
const isPresenter = () => {
|
|
|
|
const User = Users.findOne({ intId: Auth.userID });
|
|
|
|
const mappedUser = mapUser(User);
|
|
|
|
return mappedUser.isPresenter;
|
|
|
|
};
|
|
|
|
|
2018-11-02 01:55:35 +08:00
|
|
|
const isModerator = () => {
|
|
|
|
const User = Users.findOne({ intId: Auth.userID });
|
|
|
|
const mappedUser = mapUser(User);
|
|
|
|
return mappedUser.isModerator;
|
|
|
|
};
|
|
|
|
|
2018-11-05 20:27:56 +08:00
|
|
|
|
2018-10-26 23:16:29 +08:00
|
|
|
const closeBreakoutPanel = () => Session.set('breakoutRoomIsOpen', false);
|
|
|
|
|
2018-10-24 01:18:09 +08:00
|
|
|
export default {
|
2018-10-30 03:36:45 +08:00
|
|
|
findBreakouts,
|
2018-10-24 01:18:09 +08:00
|
|
|
endAllBreakouts,
|
|
|
|
requestJoinURL,
|
|
|
|
breakoutRoomUser,
|
|
|
|
transferUserToMeeting,
|
|
|
|
transferToBreakout,
|
2018-11-05 20:27:56 +08:00
|
|
|
meetingId: () => Auth.meetingID,
|
2018-10-24 01:18:09 +08:00
|
|
|
isPresenter,
|
2018-10-26 23:16:29 +08:00
|
|
|
closeBreakoutPanel,
|
2018-11-02 01:55:35 +08:00
|
|
|
isModerator,
|
2018-10-24 01:18:09 +08:00
|
|
|
};
|