bigbluebutton-Github/bigbluebutton-html5/imports/api/breakouts/server/publishers.js

56 lines
1.3 KiB
JavaScript
Raw Normal View History

import { Meteor } from 'meteor/meteor';
import Breakouts from '/imports/api/breakouts';
2019-03-08 04:23:42 +08:00
import Users from '/imports/api/users';
import Logger from '/imports/startup/server/logger';
import { extractCredentials } from '/imports/api/common/server/helpers';
const ROLE_MODERATOR = Meteor.settings.public.user.role_moderator;
function breakouts(moderator = false) {
if (!this.userId) {
return Breakouts.find({ meetingId: '' });
}
const { meetingId, requesterUserId } = extractCredentials(this.userId);
Logger.debug(`Publishing Breakouts for ${meetingId} ${requesterUserId}`);
if (moderator) {
2019-03-08 04:23:42 +08:00
const User = Users.findOne({ userId: requesterUserId });
if (!!User && User.role === ROLE_MODERATOR) {
2019-03-08 04:23:42 +08:00
const presenterSelector = {
$or: [
{ parentMeetingId: meetingId },
{ breakoutId: meetingId },
],
};
2019-03-08 04:23:42 +08:00
return Breakouts.find(presenterSelector);
}
}
2018-06-07 05:24:09 +08:00
const selector = {
$or: [
{
parentMeetingId: meetingId,
freeJoin: true,
},
{
parentMeetingId: meetingId,
'users.userId': requesterUserId,
},
{
breakoutId: meetingId,
},
],
2018-06-07 05:24:09 +08:00
};
return Breakouts.find(selector);
2017-06-06 03:12:06 +08:00
}
function publish(...args) {
const boundBreakouts = breakouts.bind(this);
return boundBreakouts(...args);
2017-06-06 03:12:06 +08:00
}
Meteor.publish('breakouts', publish);