Check presenter status outside of streamer

This commit is contained in:
Lucas Zawacki 2020-02-26 18:55:56 -03:00
parent 584c115472
commit f0d588511c
2 changed files with 26 additions and 13 deletions

View File

@ -1,22 +1,20 @@
import { Meteor } from 'meteor/meteor';
import { extractCredentials } from '/imports/api/common/server/helpers';
import Users from '/imports/api/users';
import { check } from 'meteor/check';
import Logger from '/imports/startup/server/logger';
const allowFromPresenter = (eventName, message) => {
const {
userId,
meetingId,
time,
timestamp,
rate,
state,
} = message;
const user = Users.findOne({ userId });
const ret = user && user.presenter;
Logger.info(`ExternalVideo Streamer auth userId: ${userId}, meetingId: ${meetingId}, event: ${eventName}, time: ${time}, timestamp: ${timestamp/1000} rate: ${rate}, state: ${state}`);
Logger.info(`ExternalVideo Streamer auth userid: ${userId}, meetingId: ${user.meetingId}, event: ${eventName}, suc: ${ret}, time: ${time}, rate: ${rate}, state: ${state}`);
return ret;
return true;
};
export default function initializeExternalVideo() {

View File

@ -1,5 +1,8 @@
import Meetings from '/imports/api/meetings';
import Users from '/imports/api/users';
import Auth from '/imports/ui/services/auth';
import Logger from '/imports/startup/client/logger';
import { getStreamer } from '/imports/api/external-videos';
import { makeCall } from '/imports/ui/services/api';
@ -17,13 +20,25 @@ const stopWatching = () => {
};
const sendMessage = (event, data) => {
const streamer = getStreamer(Auth.meetingID);
const {
time,
rate,
state,
timestamp,
} = data;
streamer.emit(event, {
...data,
meetingId: Auth.meetingID,
userId: Auth.userID,
});
const meetingId = Auth.meetingID;
const userId = Auth.userID;
const user = Users.findOne({ userId });
const suc = user && user.presenter;
if (!suc) {
Logger.warn("Message rejected");
} else {
const streamer = getStreamer(meetingId);
streamer.emit(event, { ...data, meetingId, userId});
}
};
const onMessage = (message, func) => {