2017-06-28 06:14:53 +08:00
|
|
|
import Auth from '/imports/ui/services/auth';
|
2021-10-20 04:35:39 +08:00
|
|
|
import Users from '/imports/api/users';
|
2017-09-25 23:39:56 +08:00
|
|
|
import { makeCall } from '/imports/ui/services/api';
|
2021-10-20 04:35:39 +08:00
|
|
|
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';
|
2023-02-17 23:44:36 +08:00
|
|
|
import NotesService from '/imports/ui/components/notes/service';
|
2021-11-20 03:34:37 +08:00
|
|
|
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;
|
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);
|
|
|
|
|
2021-11-11 21:10:31 +08:00
|
|
|
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({
|
2019-05-01 03:24:04 +08:00
|
|
|
'joinedUsers.userId': new RegExp(`^${user.userId}`),
|
|
|
|
});
|
2019-02-08 00:42:47 +08:00
|
|
|
|
2021-11-24 00:04:45 +08:00
|
|
|
const filterBreakoutUsers = (filter) => (users) => users.filter(filter);
|
2019-02-08 03:40:27 +08:00
|
|
|
|
2022-03-24 21:56:07 +08:00
|
|
|
const getUsersNotJoined = 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
|
|
|
|
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;
|
2021-02-04 21:59:13 +08:00
|
|
|
|
2016-12-21 02:06:01 +08:00
|
|
|
export default {
|
2021-01-20 22:28:37 +08:00
|
|
|
amIModerator,
|
2021-02-04 21:59:13 +08:00
|
|
|
isMe,
|
2021-03-22 01:06:16 +08:00
|
|
|
currentUser: () => Users.findOne({ meetingId: Auth.meetingID, userId: Auth.userID },
|
2023-06-08 09:10:07 +08:00
|
|
|
{
|
|
|
|
fields: {
|
|
|
|
userId: 1,
|
|
|
|
emoji: 1,
|
|
|
|
away: 1,
|
|
|
|
raiseHand: 1,
|
|
|
|
},
|
|
|
|
}),
|
2019-08-22 20:05:06 +08:00
|
|
|
meetingName: () => Meetings.findOne({ meetingId: Auth.meetingID },
|
2024-05-01 01:40:28 +08:00
|
|
|
{ fields: { 'meetingProp.name': 1 } })?.meetingProp?.name,
|
2019-08-22 20:05:06 +08:00
|
|
|
users: () => Users.find({
|
|
|
|
meetingId: Auth.meetingID,
|
|
|
|
clientType: { $ne: DIAL_IN_USER },
|
|
|
|
}).fetch(),
|
2021-11-11 21:10:31 +08:00
|
|
|
groups: () => Meetings.findOne({ meetingId: Auth.meetingID },
|
2024-05-01 01:40:28 +08:00
|
|
|
{ fields: { groups: 1 } })?.groups,
|
2019-08-22 20:05:06 +08:00
|
|
|
isBreakoutRecordable: () => Meetings.findOne({ meetingId: Auth.meetingID },
|
2024-05-01 01:40:28 +08:00
|
|
|
{ fields: { 'breakoutProps.record': 1 } })?.breakoutProps?.record,
|
2018-02-21 02:23:35 +08:00
|
|
|
toggleRecording: () => makeCall('toggleRecording'),
|
2023-06-23 02:35:40 +08:00
|
|
|
createBreakoutRoom: (rooms, durationInMinutes, record = false, captureNotes = false, captureSlides = false, sendInviteToModerators = false) => makeCall('createBreakoutRoom', rooms, durationInMinutes, record, captureNotes, captureSlides, sendInviteToModerators),
|
2018-12-28 19:51:41 +08:00
|
|
|
sendInvitation: (breakoutId, userId) => makeCall('requestJoinURL', { breakoutId, userId }),
|
2020-01-22 23:31:53 +08:00
|
|
|
breakoutJoinedUsers: () => Breakouts.find({
|
|
|
|
joinedUsers: { $exists: true },
|
|
|
|
}, { fields: { joinedUsers: 1, breakoutId: 1, sequence: 1 }, sort: { sequence: 1 } }).fetch(),
|
2022-03-24 21:56:07 +08:00
|
|
|
moveUser: (fromBreakoutId, toBreakoutId, userId) => makeCall('moveUser', fromBreakoutId, toBreakoutId, userId),
|
2018-12-28 00:20:03 +08:00
|
|
|
getBreakouts,
|
2021-11-11 21:10:31 +08:00
|
|
|
getLastBreakouts,
|
2022-03-24 21:56:07 +08:00
|
|
|
getUsersNotJoined,
|
2019-01-14 19:30:59 +08:00
|
|
|
takePresenterRole,
|
2023-02-17 23:44:36 +08:00
|
|
|
isSharedNotesPinned: () => NotesService.isSharedNotesPinned(),
|
2019-07-13 04:08:55 +08:00
|
|
|
isSharingVideo: () => getVideoUrl(),
|
2016-12-21 02:06:01 +08:00
|
|
|
};
|