bigbluebutton-Github/bigbluebutton-html5/imports/api/cursor/index.js
Oswaldo Acauan 0eb4752818 Clean up
2018-05-30 11:19:19 -03:00

41 lines
1.0 KiB
JavaScript
Executable File

import { Meteor } from 'meteor/meteor';
import Users from '/imports/api/users';
const Streamer = new Meteor.Streamer('cursor', { retransmit: false, });
if (Meteor.isServer) {
import publishCursorUpdate from './server/methods/publishCursorUpdate';
Streamer.on('publish', (message) => {
publishCursorUpdate(message.credentials, message.payload);
});
Streamer.allowRead(function(eventName, ...args) {
return true;
});
Streamer.allowEmit(function(eventName, { meetingId }) {
return this.userId && this.userId.includes(meetingId);
});
Streamer.allowWrite(function(eventName, { credentials }) {
if (!this.userId || !credentials) return false;
const { meetingId, requesterUserId: userId, requesterToken: authToken } = credentials;
const user = Users.findOne({
meetingId,
userId,
authToken,
connectionId: this.connection.id,
validated: true,
connectionStatus: 'online',
});
if (!user) return false;
return true;
});
}
export const CursorStreamer = Streamer;