Merge pull request #10396 from jfsiebel/prevent-start-stop-external-video-from-viewers
Prevent non presenters to start/stop an external video
This commit is contained in:
commit
c39bcb1ebe
@ -2,6 +2,7 @@ import { Meteor } from 'meteor/meteor';
|
||||
import { check } from 'meteor/check';
|
||||
import Logger from '/imports/startup/server/logger';
|
||||
import Meetings from '/imports/api/meetings';
|
||||
import Users from '/imports/api/users';
|
||||
import RedisPubSub from '/imports/startup/server/redis';
|
||||
import { extractCredentials } from '/imports/api/common/server/helpers';
|
||||
|
||||
@ -10,21 +11,28 @@ export default function startWatchingExternalVideo(options) {
|
||||
const CHANNEL = REDIS_CONFIG.channels.toAkkaApps;
|
||||
const EVENT_NAME = 'StartExternalVideoMsg';
|
||||
|
||||
const { meetingId, requesterUserId } = extractCredentials(this.userId);
|
||||
const { meetingId, requesterUserId: userId } = extractCredentials(this.userId);
|
||||
const { externalVideoUrl } = options;
|
||||
|
||||
try {
|
||||
check(meetingId, String);
|
||||
check(requesterUserId, String);
|
||||
check(userId, String);
|
||||
check(externalVideoUrl, String);
|
||||
|
||||
const user = Users.findOne({ meetingId, userId, presenter: true }, { presenter: 1 });
|
||||
|
||||
if (!user) {
|
||||
Logger.error(`Only presenters are allowed to start external video for a meeting. meeting=${meetingId} userId=${userId}`);
|
||||
return;
|
||||
}
|
||||
|
||||
Meetings.update({ meetingId }, { $set: { externalVideoUrl } });
|
||||
|
||||
const payload = { externalVideoUrl };
|
||||
|
||||
Logger.info(`User id=${requesterUserId} sharing an external video: ${externalVideoUrl} for meeting ${meetingId}`);
|
||||
Logger.info(`User id=${userId} sharing an external video: ${externalVideoUrl} for meeting ${meetingId}`);
|
||||
|
||||
return RedisPubSub.publishUserMessage(CHANNEL, EVENT_NAME, meetingId, requesterUserId, payload);
|
||||
return RedisPubSub.publishUserMessage(CHANNEL, EVENT_NAME, meetingId, userId, payload);
|
||||
} catch (error) {
|
||||
Logger.error(`Error on sharing an external video: ${externalVideoUrl} ${error}`);
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
import { Meteor } from 'meteor/meteor';
|
||||
import Logger from '/imports/startup/server/logger';
|
||||
import Meetings from '/imports/api/meetings';
|
||||
import Users from '/imports/api/users';
|
||||
import RedisPubSub from '/imports/startup/server/redis';
|
||||
import { extractCredentials } from '/imports/api/common/server/helpers';
|
||||
|
||||
@ -15,6 +16,17 @@ export default function stopWatchingExternalVideo(options) {
|
||||
check(meetingId, String);
|
||||
check(requesterUserId, String);
|
||||
|
||||
const user = Users.findOne({
|
||||
meetingId,
|
||||
userId: requesterUserId,
|
||||
presenter: true,
|
||||
}, { presenter: 1 });
|
||||
|
||||
if (this.userId && !user) {
|
||||
Logger.error(`Only presenters are allowed to stop external video for a meeting. meeting=${meetingId} userId=${requesterUserId}`);
|
||||
return;
|
||||
}
|
||||
|
||||
const meeting = Meetings.findOne({ meetingId });
|
||||
if (!meeting || meeting.externalVideoUrl === null) return;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user