bigbluebutton-Github/bigbluebutton-html5/imports/api/video-streams/server/helpers.js

29 lines
722 B
JavaScript
Raw Normal View History

2019-11-23 05:08:27 +08:00
import Logger from '/imports/startup/server/logger';
2019-11-27 04:31:41 +08:00
import Users from '/imports/api/users';
2019-11-23 05:08:27 +08:00
const FLASH_STREAM_REGEX = /^([A-z0-9]+)-([A-z0-9]+)-([A-z0-9]+)(-recorded)?$/;
const TOKEN = '_';
2019-11-27 04:31:41 +08:00
const isValidStream = stream => !FLASH_STREAM_REGEX.test(stream);
2019-11-23 05:08:27 +08:00
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, meetingId) => {
2019-11-27 04:31:41 +08:00
const user = Users.findOne(
{ userId, meetingId },
2019-11-27 04:31:41 +08:00
{ fields: { name: 1 } },
);
if (user) return user.name;
return userId;
};
2019-11-23 05:08:27 +08:00
export {
isValidStream,
getDeviceId,
2019-11-27 04:31:41 +08:00
getUserName,
2019-11-23 05:08:27 +08:00
};