skip share/unshare webcam using if not check

This commit is contained in:
Tainan Felipe 2018-06-18 15:35:27 -03:00
parent ba56751546
commit 9e9e85cddb
2 changed files with 12 additions and 10 deletions

View File

@ -3,17 +3,18 @@ import { check } from 'meteor/check';
export default function handleUserSharedHtml5Webcam({ header, body }, meetingId ) {
const { userId, stream } = body;
const isValidStream = Match.Where((stream) => {
check(stream, String);
const isValidStream = (match) => {
// Checking if the stream name is a flash one
const regexp = /^([A-z0-9]+)-([A-z0-9]+)-([A-z0-9]+)(-recorded)?$/;
return !regexp.test(stream);
});
return !regexp.test(match);
};
check(header, Object);
check(meetingId, String);
check(userId, String);
check(stream, isValidStream);
check(stream, String);
if (!isValidStream(stream)) return false;
return sharedWebcam(meetingId, userId);
}

View File

@ -3,17 +3,18 @@ import { check } from 'meteor/check';
export default function handleUserUnsharedHtml5Webcam({ header, body }, meetingId) {
const { userId, stream } = body;
const isValidStream = Match.Where((stream) => {
check(stream, String);
const isValidStream = (match) => {
// Checking if the stream name is a flash one
const regexp = /^([A-z0-9]+)-([A-z0-9]+)-([A-z0-9]+)(-recorded)?$/;
return !regexp.test(stream);
});
return !regexp.test(match);
};
check(header, Object);
check(meetingId, String);
check(userId, String);
check(stream, isValidStream);
check(stream, String);
if (!isValidStream(stream)) return false;
return unsharedWebcam(meetingId, userId);
}