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

80 lines
3.0 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';
import Meetings from '/imports/api/meetings';
import Breakouts from '/imports/api/breakouts';
2019-07-13 04:08:55 +08:00
import { getVideoUrl } from '/imports/ui/components/external-video-player/service';
import NotesService from '/imports/ui/components/notes/service';
import BreakoutsHistory from '/imports/api/breakouts-history';
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 getLastBreakouts = () => {
const lastBreakouts = BreakoutsHistory.findOne({ meetingId: Auth.meetingID });
if (lastBreakouts) {
return lastBreakouts.rooms
.sort((a, b) => a.sequence - b.sequence);
}
return [];
};
2021-11-24 00:04:45 +08:00
const currentBreakoutUsers = (user) => !Breakouts.findOne({
'joinedUsers.userId': new RegExp(`^${user.userId}`),
});
2021-11-24 00:04:45 +08:00
const filterBreakoutUsers = (filter) => (users) => users.filter(filter);
const getUsersNotJoined = 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 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;
};
2021-11-24 00:04:45 +08:00
const isMe = (intId) => intId === Auth.userID;
export default {
2021-01-20 22:28:37 +08:00
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(),
groups: () => Meetings.findOne({ meetingId: Auth.meetingID },
{ fields: { groups: 1 } }).groups,
isBreakoutRecordable: () => Meetings.findOne({ meetingId: Auth.meetingID },
{ fields: { 'breakoutProps.record': 1 } }).breakoutProps.record,
toggleRecording: () => makeCall('toggleRecording'),
createBreakoutRoom: (rooms, durationInMinutes, record = false, captureNotes = false, captureSlides = false) => makeCall('createBreakoutRoom', rooms, durationInMinutes, record, captureNotes, captureSlides),
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(),
moveUser: (fromBreakoutId, toBreakoutId, userId) => makeCall('moveUser', fromBreakoutId, toBreakoutId, userId),
2018-12-28 00:20:03 +08:00
getBreakouts,
getLastBreakouts,
getUsersNotJoined,
takePresenterRole,
isSharedNotesPinned: () => NotesService.isSharedNotesPinned(),
2019-07-13 04:08:55 +08:00
isSharingVideo: () => getVideoUrl(),
};