bigbluebutton-Github/bigbluebutton-html5/imports/ui/components/actions-bar/service.js

39 lines
1.8 KiB
JavaScript
Raw Normal View History

import Auth from '/imports/ui/services/auth';
import Users from '/imports/api/users';
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';
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;
2018-12-28 00:20:03 +08:00
const getBreakouts = () => Breakouts.find({ parentMeetingId: Auth.meetingID })
.fetch()
.sort((a, b) => a.sequence - b.sequence);
const getUsersNotAssigned = (users) => {
const breakouts = getBreakouts();
const breakoutUsers = breakouts
.reduce((acc, value) => [...acc, ...value.users], [])
.map(u => u.userId);
return users.filter(u => !breakoutUsers.includes(u.intId));
};
2019-01-17 01:41:21 +08:00
const takePresenterRole = () => makeCall('assignPresenter', Auth.userID);
2018-11-13 06:09:04 +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,
users: () => Users.find({ connectionStatus: 'online' }).fetch(),
2018-10-24 01:18:09 +08:00
hasBreakoutRoom: () => Breakouts.find({ parentMeetingId: Auth.meetingID }).fetch().length > 0,
toggleRecording: () => makeCall('toggleRecording'),
2018-10-24 01:18:09 +08:00
createBreakoutRoom: (numberOfRooms, durationInMinutes, freeJoin = true, record = false) => makeCall('createBreakoutRoom', numberOfRooms, durationInMinutes, freeJoin, 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,
takePresenterRole,
};