2017-06-28 06:14:53 +08:00
|
|
|
import Auth from '/imports/ui/services/auth';
|
2017-10-12 10:00:28 +08:00
|
|
|
import Users from '/imports/api/users';
|
2017-09-25 23:39:56 +08:00
|
|
|
import { makeCall } from '/imports/ui/services/api';
|
2018-02-16 03:42:50 +08:00
|
|
|
import Meetings from '/imports/api/meetings';
|
2018-10-24 01:18:09 +08:00
|
|
|
import Breakouts from '/imports/api/breakouts';
|
2019-02-16 01:32:03 +08:00
|
|
|
import { getVideoId } from '/imports/ui/components/external-video-player/service';
|
2018-02-16 03:42:50 +08:00
|
|
|
|
2019-02-12 07:35:36 +08:00
|
|
|
const USER_CONFIG = Meteor.settings.public.user;
|
|
|
|
const ROLE_MODERATOR = USER_CONFIG.role_moderator;
|
2019-05-23 04:06:21 +08:00
|
|
|
const DIAL_IN_USER = 'dial-in-user';
|
2019-02-12 07:35:36 +08:00
|
|
|
|
2018-12-28 00:20:03 +08:00
|
|
|
const getBreakouts = () => Breakouts.find({ parentMeetingId: Auth.meetingID })
|
|
|
|
.fetch()
|
|
|
|
.sort((a, b) => a.sequence - b.sequence);
|
|
|
|
|
2019-05-01 03:24:04 +08:00
|
|
|
const currentBreakoutUsers = user => !Breakouts.findOne({
|
|
|
|
'joinedUsers.userId': new RegExp(`^${user.userId}`),
|
|
|
|
});
|
2019-02-08 00:42:47 +08:00
|
|
|
|
2019-02-08 03:40:27 +08:00
|
|
|
const filterBreakoutUsers = filter => users => users.filter(filter);
|
|
|
|
|
2019-05-01 03:24:04 +08:00
|
|
|
const getUsersNotAssigned = filterBreakoutUsers(currentBreakoutUsers);
|
2019-01-17 01:41:21 +08:00
|
|
|
|
2019-01-14 19:30:59 +08:00
|
|
|
const takePresenterRole = () => makeCall('assignPresenter', Auth.userID);
|
2018-11-13 06:09:04 +08:00
|
|
|
|
2016-12-21 02:06:01 +08:00
|
|
|
export default {
|
2017-11-24 01:20:27 +08:00
|
|
|
isUserPresenter: () => Users.findOne({ userId: Auth.userID }).presenter,
|
2019-02-12 07:35:36 +08:00
|
|
|
isUserModerator: () => Users.findOne({ userId: Auth.userID }).role === ROLE_MODERATOR,
|
2018-02-28 22:10:00 +08:00
|
|
|
recordSettingsList: () => Meetings.findOne({ meetingId: Auth.meetingID }).recordProp,
|
2018-10-24 01:18:09 +08:00
|
|
|
meetingIsBreakout: () => Meetings.findOne({ meetingId: Auth.meetingID }).meetingProp.isBreakout,
|
2018-10-30 03:29:45 +08:00
|
|
|
meetingName: () => Meetings.findOne({ meetingId: Auth.meetingID }).meetingProp.name,
|
2019-05-23 04:06:21 +08:00
|
|
|
users: () => Users.find({ connectionStatus: 'online', meetingId: Auth.meetingID, clientType: { $ne: DIAL_IN_USER } }).fetch(),
|
2018-10-24 01:18:09 +08:00
|
|
|
hasBreakoutRoom: () => Breakouts.find({ parentMeetingId: Auth.meetingID }).fetch().length > 0,
|
2019-04-10 22:58:34 +08:00
|
|
|
isBreakoutEnabled: () => Meetings.findOne({ meetingId: Auth.meetingID }).breakoutProps.enabled,
|
2019-04-13 01:21:28 +08:00
|
|
|
isBreakoutRecordable: () => Meetings.findOne({ meetingId: Auth.meetingID }).breakoutProps.record,
|
2018-02-21 02:23:35 +08:00
|
|
|
toggleRecording: () => makeCall('toggleRecording'),
|
2019-04-12 04:12:22 +08:00
|
|
|
createBreakoutRoom: (numberOfRooms, durationInMinutes, record = false) => makeCall('createBreakoutRoom', numberOfRooms, durationInMinutes, record),
|
2018-12-28 19:51:41 +08:00
|
|
|
sendInvitation: (breakoutId, userId) => makeCall('requestJoinURL', { breakoutId, userId }),
|
2018-12-28 00:20:03 +08:00
|
|
|
getBreakouts,
|
|
|
|
getUsersNotAssigned,
|
2019-01-14 19:30:59 +08:00
|
|
|
takePresenterRole,
|
2019-02-16 01:32:03 +08:00
|
|
|
isSharingVideo: () => getVideoId(),
|
2016-12-21 02:06:01 +08:00
|
|
|
};
|