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

79 lines
2.1 KiB
JavaScript
Raw Normal View History

2016-10-22 00:27:47 +08:00
import { Meteor } from 'meteor/meteor';
import { check } from 'meteor/check';
2019-09-09 22:48:50 +08:00
import Meetings, { RecordMeetings, MeetingTimeRemaining } from '/imports/api/meetings';
2019-03-08 04:23:42 +08:00
import Users from '/imports/api/users';
2016-10-22 00:27:47 +08:00
import Logger from '/imports/startup/server/logger';
const ROLE_MODERATOR = Meteor.settings.public.user.role_moderator;
2019-03-08 00:33:34 +08:00
function meetings(credentials, isModerator = false) {
2016-10-22 00:27:47 +08:00
const { meetingId, requesterUserId, requesterToken } = credentials;
check(meetingId, String);
check(requesterUserId, String);
check(requesterToken, String);
Logger.debug(`Publishing meeting =${meetingId} ${requesterUserId} ${requesterToken}`);
2016-10-22 00:27:47 +08:00
const selector = {
2018-10-17 01:55:20 +08:00
$or: [
{ meetingId },
],
};
2019-03-08 00:33:34 +08:00
if (isModerator) {
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
selector.$or.push({
'meetingProp.isBreakout': true,
'breakoutProps.parentId': meetingId,
});
}
2019-03-08 00:33:34 +08:00
}
const options = {
fields: {
password: false,
},
};
return Meetings.find(selector, options);
2017-06-06 03:12:06 +08:00
}
function publish(...args) {
const boundMeetings = meetings.bind(this);
return boundMeetings(...args);
2017-06-06 03:12:06 +08:00
}
Meteor.publish('meetings', publish);
function recordMeetings(credentials) {
const { meetingId, requesterUserId, requesterToken } = credentials;
check(meetingId, String);
check(requesterUserId, String);
check(requesterToken, String);
return RecordMeetings.find({ meetingId });
}
function recordPublish(...args) {
const boundRecordMeetings = recordMeetings.bind(this);
return boundRecordMeetings(...args);
}
Meteor.publish('record-meetings', recordPublish);
function meetingTimeRemaining(credentials) {
const { meetingId, requesterUserId, requesterToken } = credentials;
check(meetingId, String);
check(requesterUserId, String);
check(requesterToken, String);
2019-09-09 22:48:50 +08:00
return MeetingTimeRemaining.find({ meetingId });
}
function timeRemainingPublish(...args) {
const boundtimeRemaining = meetingTimeRemaining.bind(this);
return boundtimeRemaining(...args);
}
Meteor.publish('meeting-time-remaining', timeRemainingPublish);