2019-03-29 02:47:11 +08:00
|
|
|
import { Meteor } from 'meteor/meteor';
|
|
|
|
import Logger from '/imports/startup/server/logger';
|
|
|
|
import Note from '/imports/api/note';
|
2020-09-02 00:31:11 +08:00
|
|
|
import AuthTokenValidation, { ValidationStates } from '/imports/api/auth-token-validation';
|
2019-03-29 02:47:11 +08:00
|
|
|
|
2020-02-07 04:47:28 +08:00
|
|
|
function note() {
|
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 Note was requested by unauth connection ${this.connection.id}`);
|
2020-02-07 04:47:28 +08:00
|
|
|
return Note.find({ meetingId: '' });
|
|
|
|
}
|
2019-03-29 02:47:11 +08:00
|
|
|
|
2020-09-02 00:31:11 +08:00
|
|
|
const { meetingId, userId } = tokenValidation;
|
|
|
|
|
|
|
|
Logger.info(`Publishing Note for ${meetingId} ${userId}`);
|
2019-03-29 02:47:11 +08:00
|
|
|
|
|
|
|
return Note.find({ meetingId });
|
|
|
|
}
|
|
|
|
|
|
|
|
function publish(...args) {
|
|
|
|
const boundNote = note.bind(this);
|
|
|
|
return boundNote(...args);
|
|
|
|
}
|
|
|
|
|
|
|
|
Meteor.publish('note', publish);
|