2016-10-22 00:27:47 +08:00
|
|
|
import { Meteor } from 'meteor/meteor';
|
2021-05-27 03:09:25 +08:00
|
|
|
import Meetings, {
|
|
|
|
RecordMeetings,
|
|
|
|
MeetingTimeRemaining,
|
|
|
|
ExternalVideoMeetings,
|
|
|
|
} 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';
|
2020-09-02 00:31:11 +08:00
|
|
|
import AuthTokenValidation, { ValidationStates } from '/imports/api/auth-token-validation';
|
2016-10-22 00:27:47 +08:00
|
|
|
|
2019-06-29 04:52:19 +08:00
|
|
|
const ROLE_MODERATOR = Meteor.settings.public.user.role_moderator;
|
|
|
|
|
2020-06-05 21:32:05 +08:00
|
|
|
function meetings(role) {
|
2020-09-02 00:31:11 +08:00
|
|
|
const tokenValidation = AuthTokenValidation.findOne({ connectionId: this.connection.id });
|
|
|
|
|
|
|
|
if (!tokenValidation || tokenValidation.validationStatus !== ValidationStates.VALIDATED) {
|
|
|
|
Logger.warn(`Publishing Meetings was requested by unauth connection ${this.connection.id}`);
|
2020-02-07 04:47:28 +08:00
|
|
|
return Meetings.find({ meetingId: '' });
|
|
|
|
}
|
2016-10-22 00:27:47 +08:00
|
|
|
|
2020-09-02 00:31:11 +08:00
|
|
|
const { meetingId, userId } = tokenValidation;
|
|
|
|
|
2020-11-24 23:13:09 +08:00
|
|
|
Logger.debug('Publishing meeting', { meetingId, userId });
|
2016-10-22 00:27:47 +08:00
|
|
|
|
2018-09-10 23:34:25 +08:00
|
|
|
const selector = {
|
2018-10-17 01:55:20 +08:00
|
|
|
$or: [
|
|
|
|
{ meetingId },
|
|
|
|
],
|
2018-09-10 23:34:25 +08:00
|
|
|
};
|
|
|
|
|
2020-09-02 00:31:11 +08:00
|
|
|
const User = Users.findOne({ userId, meetingId }, { fields: { role: 1 } });
|
2020-05-21 05:07:36 +08:00
|
|
|
if (!!User && User.role === ROLE_MODERATOR) {
|
|
|
|
selector.$or.push({
|
|
|
|
'meetingProp.isBreakout': true,
|
|
|
|
'breakoutProps.parentId': meetingId,
|
|
|
|
});
|
2019-03-08 00:33:34 +08:00
|
|
|
}
|
|
|
|
|
2018-09-10 23:34:25 +08:00
|
|
|
const options = {
|
|
|
|
fields: {
|
|
|
|
password: false,
|
2020-05-21 03:54:08 +08:00
|
|
|
'welcomeProp.modOnlyMessage': false,
|
2018-09-10 23:34:25 +08:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2021-10-15 01:00:25 +08:00
|
|
|
if (User.role !== ROLE_MODERATOR) {
|
|
|
|
options.fields.learningDashboardAccessToken = false;
|
2021-07-16 08:23:16 +08:00
|
|
|
}
|
|
|
|
|
2018-09-10 23:34:25 +08:00
|
|
|
return Meetings.find(selector, options);
|
2017-06-06 03:12:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
function publish(...args) {
|
|
|
|
const boundMeetings = meetings.bind(this);
|
2018-11-06 03:30:37 +08:00
|
|
|
return boundMeetings(...args);
|
2017-06-06 03:12:06 +08:00
|
|
|
}
|
|
|
|
|
2017-10-13 03:07:02 +08:00
|
|
|
Meteor.publish('meetings', publish);
|
2019-08-22 01:42:37 +08:00
|
|
|
|
2020-02-07 04:47:28 +08:00
|
|
|
function recordMeetings() {
|
2020-09-02 00:31:11 +08:00
|
|
|
const tokenValidation = AuthTokenValidation.findOne({ connectionId: this.connection.id });
|
|
|
|
|
|
|
|
if (!tokenValidation || tokenValidation.validationStatus !== ValidationStates.VALIDATED) {
|
|
|
|
Logger.warn(`Publishing RecordMeetings was requested by unauth connection ${this.connection.id}`);
|
2020-02-07 04:47:28 +08:00
|
|
|
return RecordMeetings.find({ meetingId: '' });
|
|
|
|
}
|
2020-09-02 00:31:11 +08:00
|
|
|
|
|
|
|
const { meetingId, userId } = tokenValidation;
|
|
|
|
|
|
|
|
Logger.debug(`Publishing RecordMeetings for ${meetingId} ${userId}`);
|
2019-08-22 01:42:37 +08:00
|
|
|
|
|
|
|
return RecordMeetings.find({ meetingId });
|
|
|
|
}
|
|
|
|
function recordPublish(...args) {
|
2019-09-09 22:29:59 +08:00
|
|
|
const boundRecordMeetings = recordMeetings.bind(this);
|
|
|
|
return boundRecordMeetings(...args);
|
2019-08-22 01:42:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
Meteor.publish('record-meetings', recordPublish);
|
2019-09-09 22:29:59 +08:00
|
|
|
|
2021-05-27 03:09:25 +08:00
|
|
|
function externalVideoMeetings() {
|
|
|
|
const tokenValidation = AuthTokenValidation.findOne({ connectionId: this.connection.id });
|
|
|
|
|
|
|
|
if (!tokenValidation || tokenValidation.validationStatus !== ValidationStates.VALIDATED) {
|
|
|
|
Logger.warn(`Publishing ExternalVideoMeetings was requested by unauth connection ${this.connection.id}`);
|
|
|
|
return ExternalVideoMeetings.find({ meetingId: '' });
|
|
|
|
}
|
|
|
|
|
|
|
|
const { meetingId, userId } = tokenValidation;
|
|
|
|
|
|
|
|
Logger.debug(`Publishing ExternalVideoMeetings for ${meetingId} ${userId}`);
|
|
|
|
|
|
|
|
return ExternalVideoMeetings.find({ meetingId });
|
|
|
|
}
|
|
|
|
|
|
|
|
function externalVideoPublish(...args) {
|
|
|
|
const boundExternalVideoMeetings = externalVideoMeetings.bind(this);
|
|
|
|
return boundExternalVideoMeetings(...args);
|
|
|
|
}
|
|
|
|
|
|
|
|
Meteor.publish('external-video-meetings', externalVideoPublish);
|
|
|
|
|
2020-02-07 04:47:28 +08:00
|
|
|
function meetingTimeRemaining() {
|
2020-09-02 00:31:11 +08:00
|
|
|
const tokenValidation = AuthTokenValidation.findOne({ connectionId: this.connection.id });
|
|
|
|
|
|
|
|
if (!tokenValidation || tokenValidation.validationStatus !== ValidationStates.VALIDATED) {
|
|
|
|
Logger.warn(`Publishing MeetingTimeRemaining was requested by unauth connection ${this.connection.id}`);
|
2020-02-07 04:47:28 +08:00
|
|
|
return MeetingTimeRemaining.find({ meetingId: '' });
|
|
|
|
}
|
2020-09-02 00:31:11 +08:00
|
|
|
|
|
|
|
const { meetingId, userId } = tokenValidation;
|
|
|
|
Logger.debug(`Publishing MeetingTimeRemaining for ${meetingId} ${userId}`);
|
2019-09-09 22:29:59 +08:00
|
|
|
|
2019-09-09 22:48:50 +08:00
|
|
|
return MeetingTimeRemaining.find({ meetingId });
|
2019-09-09 22:29:59 +08:00
|
|
|
}
|
|
|
|
function timeRemainingPublish(...args) {
|
|
|
|
const boundtimeRemaining = meetingTimeRemaining.bind(this);
|
|
|
|
return boundtimeRemaining(...args);
|
|
|
|
}
|
|
|
|
|
|
|
|
Meteor.publish('meeting-time-remaining', timeRemainingPublish);
|