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

78 lines
2.6 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';
2019-07-13 04:08:55 +08:00
import { getVideoUrl } 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;
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);
const currentBreakoutUsers = user => !Breakouts.findOne({
'joinedUsers.userId': new RegExp(`^${user.userId}`),
});
const filterBreakoutUsers = filter => users => users.filter(filter);
const getUsersNotAssigned = filterBreakoutUsers(currentBreakoutUsers);
2019-01-17 01:41:21 +08:00
const takePresenterRole = () => makeCall('assignPresenter', Auth.userID);
2018-11-13 06:09:04 +08:00
2021-01-20 22:28:37 +08:00
const amIPresenter = () => {
const currentUser = Users.findOne({ userId: Auth.userID },
{ fields: { presenter: 1 } });
2021-01-20 22:39:47 +08:00
if (!currentUser) {
2021-01-20 22:28:37 +08:00
return false;
}
return currentUser.presenter;
};
const amIModerator = () => {
const currentUser = Users.findOne({ userId: Auth.userID },
{ fields: { role: 1 } });
2021-01-20 22:39:47 +08:00
if (!currentUser) {
2021-01-20 22:28:37 +08:00
return false;
}
return currentUser.role === ROLE_MODERATOR;
};
const isMe = intId => intId === Auth.userID;
export default {
2021-01-20 22:28:37 +08:00
amIPresenter,
amIModerator,
isMe,
currentUser: () => Users.findOne({ meetingId: Auth.meetingID, userId: Auth.userID },
{ fields: { userId: 1, emoji: 1 } }),
meetingName: () => Meetings.findOne({ meetingId: Auth.meetingID },
{ fields: { 'meetingProp.name': 1 } }).meetingProp.name,
users: () => Users.find({
meetingId: Auth.meetingID,
clientType: { $ne: DIAL_IN_USER },
}).fetch(),
isBreakoutEnabled: () => Meetings.findOne({ meetingId: Auth.meetingID },
{ fields: { 'breakoutProps.enabled': 1 } }).breakoutProps.enabled,
isBreakoutRecordable: () => Meetings.findOne({ meetingId: Auth.meetingID },
{ fields: { 'breakoutProps.record': 1 } }).breakoutProps.record,
toggleRecording: () => makeCall('toggleRecording'),
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 }),
breakoutJoinedUsers: () => Breakouts.find({
joinedUsers: { $exists: true },
}, { fields: { joinedUsers: 1, breakoutId: 1, sequence: 1 }, sort: { sequence: 1 } }).fetch(),
2018-12-28 00:20:03 +08:00
getBreakouts,
getUsersNotAssigned,
takePresenterRole,
2019-07-13 04:08:55 +08:00
isSharingVideo: () => getVideoUrl(),
};