2018-04-06 03:59:26 +08:00
|
|
|
import { Meteor } from 'meteor/meteor';
|
2018-04-10 11:57:24 +08:00
|
|
|
import PresentationPods from '/imports/api/presentation-pods';
|
2018-04-06 03:59:26 +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';
|
2018-04-06 03:59:26 +08:00
|
|
|
|
2023-03-15 03:50:35 +08:00
|
|
|
async function presentationPods() {
|
|
|
|
const tokenValidation = await AuthTokenValidation
|
|
|
|
.findOneAsync({ connectionId: this.connection.id });
|
2020-09-02 00:31:11 +08:00
|
|
|
|
|
|
|
if (!tokenValidation || tokenValidation.validationStatus !== ValidationStates.VALIDATED) {
|
|
|
|
Logger.warn(`Publishing PresentationPods was requested by unauth connection ${this.connection.id}`);
|
2020-02-07 04:47:28 +08:00
|
|
|
return PresentationPods.find({ meetingId: '' });
|
|
|
|
}
|
2020-09-02 00:31:11 +08:00
|
|
|
|
|
|
|
const { meetingId, userId } = tokenValidation;
|
2020-11-24 23:13:09 +08:00
|
|
|
Logger.debug('Publishing presentation-pods', { meetingId, userId });
|
2018-04-06 03:59:26 +08:00
|
|
|
|
|
|
|
return PresentationPods.find({ meetingId });
|
|
|
|
}
|
|
|
|
|
|
|
|
function publish(...args) {
|
|
|
|
const boundPresentationPods = presentationPods.bind(this);
|
2018-11-06 03:30:37 +08:00
|
|
|
return boundPresentationPods(...args);
|
2018-04-06 03:59:26 +08:00
|
|
|
}
|
|
|
|
|
2018-04-10 11:57:24 +08:00
|
|
|
Meteor.publish('presentation-pods', publish);
|