bigbluebutton-Github/bigbluebutton-html5/imports/api/video-streams/server/helpers.js
2019-12-10 08:21:20 -03:00

29 lines
700 B
JavaScript

import Logger from '/imports/startup/server/logger';
import Users from '/imports/api/users';
const FLASH_STREAM_REGEX = /^([A-z0-9]+)-([A-z0-9]+)-([A-z0-9]+)(-recorded)?$/;
const TOKEN = '_';
const isValidStream = stream => !FLASH_STREAM_REGEX.test(stream);
const getDeviceId = (stream) => {
const splitStream = stream.split(TOKEN);
if (splitStream.length === 3) return splitStream[2];
Logger.warn(`Could not get deviceId from stream=${stream}`);
return stream;
};
const getUserName = (userId) => {
const user = Users.findOne(
{ userId },
{ fields: { name: 1 } },
);
if (user) return user.name;
return userId;
};
export {
isValidStream,
getDeviceId,
getUserName,
};