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

49 lines
1.2 KiB
JavaScript
Executable File

import { Meteor } from 'meteor/meteor';
import { check } from 'meteor/check';
import Meetings from '/imports/api/meetings';
import Users from '/imports/api/users';
import Logger from '/imports/startup/server/logger';
const ROLE_MODERATOR = Meteor.settings.public.user.role_moderator;
function meetings(credentials, isModerator = false) {
const { meetingId, requesterUserId, requesterToken } = credentials;
check(meetingId, String);
check(requesterUserId, String);
check(requesterToken, String);
Logger.debug(`Publishing meeting =${meetingId} ${requesterUserId} ${requesterToken}`);
const selector = {
$or: [
{ meetingId },
],
};
if (isModerator) {
const User = Users.findOne({ userId: requesterUserId });
if (!!User && User.role === ROLE_MODERATOR) {
selector.$or.push({
'meetingProp.isBreakout': true,
'breakoutProps.parentId': meetingId,
});
}
}
const options = {
fields: {
password: false,
},
};
return Meetings.find(selector, options);
}
function publish(...args) {
const boundMeetings = meetings.bind(this);
return boundMeetings(...args);
}
Meteor.publish('meetings', publish);