Merge pull request #5307 from Tainan404/webcam-only-moderator

Comply lock setting "see other viewer's webcams"
This commit is contained in:
Oswaldo Acauan 2018-04-04 16:36:16 -03:00 committed by GitHub
commit 2cb81d3428
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 30 additions and 27 deletions

View File

@ -1,8 +1,6 @@
import React, { Component } from 'react'; import React, { Component } from 'react';
import { withTracker } from 'meteor/react-meteor-data'; import { withTracker } from 'meteor/react-meteor-data';
import Settings from '/imports/ui/services/settings'; import Settings from '/imports/ui/services/settings';
import Meetings from '/imports/api/meetings/';
import Auth from '/imports/ui/services/auth';
import { defineMessages, injectIntl } from 'react-intl'; import { defineMessages, injectIntl } from 'react-intl';
import { notify } from '/imports/ui/services/notification'; import { notify } from '/imports/ui/services/notification';
import Media from './component'; import Media from './component';
@ -85,9 +83,6 @@ export default withTracker(() => {
const data = {}; const data = {};
data.currentPresentation = MediaService.getPresentationInfo(); data.currentPresentation = MediaService.getPresentationInfo();
const meeting = Meetings.findOne({ meetingId: Auth.meetingID });
const webcamOnlyModerator = meeting.usersProp.webcamsOnlyForModerator;
data.content = <DefaultContent />; data.content = <DefaultContent />;
if (MediaService.shouldShowWhiteboard()) { if (MediaService.shouldShowWhiteboard()) {
@ -98,7 +93,7 @@ export default withTracker(() => {
data.content = <ScreenshareContainer />; data.content = <ScreenshareContainer />;
} }
if (MediaService.shouldShowOverlay() && viewParticipantsWebcams && !webcamOnlyModerator) { if (MediaService.shouldShowOverlay() && viewParticipantsWebcams) {
data.overlay = <VideoProviderContainer />; data.overlay = <VideoProviderContainer />;
} }

View File

@ -86,11 +86,11 @@ class VideoDock extends Component {
<div id="webcamArea" className={styles.webcamArea}> <div id="webcamArea" className={styles.webcamArea}>
{this.props.users.map(user => ( {this.props.users.map(user => (
<VideoElement <VideoElement
shared={id === user.userId && sharedWebcam} shared={id === user.id && sharedWebcam}
videoId={user.userId} videoId={user.id}
key={user.userId} key={user.id}
name={user.name} name={user.name}
localCamera={id === user.userId} localCamera={id === user.id}
onShareWebcam={this.props.onShareWebcam.bind(this)} onShareWebcam={this.props.onShareWebcam.bind(this)}
onMount={this.props.onStart.bind(this)} onMount={this.props.onStart.bind(this)}
onUnmount={this.props.onStop.bind(this)} onUnmount={this.props.onStop.bind(this)}

View File

@ -1,34 +1,40 @@
import React from 'react'; import React from 'react';
import { withTracker } from 'meteor/react-meteor-data'; import { withTracker } from 'meteor/react-meteor-data';
import Auth from '/imports/ui/services/auth'; import Auth from '/imports/ui/services/auth';
import mapUser from '../../../services/user/mapUser';
import Meetings from '/imports/api/meetings/'; import Meetings from '/imports/api/meetings/';
import Users from '/imports/api/users/'; import Users from '/imports/api/users/';
import mapUser from '/imports/ui/services/user/mapUser';
import VideoDock from './component'; import VideoDock from './component';
import VideoService from '../service'; import VideoService from '../service';
const VideoDockContainer = ({ children, ...props }) => <VideoDock {...props}>{children}</VideoDock>; const VideoDockContainer = ({ children, ...props }) => <VideoDock {...props}>{children}</VideoDock>;
export default withTracker(({sharedWebcam}) => { export default withTracker(({ sharedWebcam }) => {
const meeting = Meetings.findOne({ meetingId: Auth.meetingID }); const meeting = Meetings.findOne({ meetingId: Auth.meetingID });
const lockCam = meeting.lockSettingsProp ? meeting.lockSettingsProp.disableCam : false; const lockCam = meeting.lockSettingsProp ? meeting.lockSettingsProp.disableCam : false;
const userId = Auth.userID; const userId = Auth.userID;
const user = Users.findOne({ userId }); const currentUser = Users.findOne({ userId });
const userLocked = mapUser(user).isLocked; const currentUserIsModerator = mapUser(currentUser).isModerator;
const withActiveStreams = (users) => { const isSharingWebcam = user => user.isSharingWebcam || (sharedWebcam && user.isCurrent);
const activeFilter = (user) => { const isNotLocked = user => !(lockCam && user.isLocked);
const isLocked = lockCam && user.locked;
return !isLocked && (user.has_stream || (sharedWebcam && user.userId == userId));
};
return users.filter(activeFilter);
}
const users = withActiveStreams(VideoService.getAllUsers()); const isWebcamOnlyModerator = VideoService.webcamOnlyModerator();
const allowedSeeViewersWebcams = !isWebcamOnlyModerator || currentUserIsModerator;
const webcamOnlyModerator = (user) => {
if (allowedSeeViewersWebcams) return true;
return user.isModerator || user.isCurrent;
};
const users = VideoService.getAllUsers()
.map(mapUser)
.filter(isSharingWebcam)
.filter(isNotLocked)
.filter(webcamOnlyModerator);
return { return {
users, users,
userId userId,
}; };
})(VideoDockContainer); })(VideoDockContainer);

View File

@ -46,7 +46,7 @@ const JoinVideoOptionsContainer = (props) => {
iconPath: `${baseName}/resources/images/video-menu/icon-webcam-off.svg`, iconPath: `${baseName}/resources/images/video-menu/icon-webcam-off.svg`,
description: intl.formatMessage(intlMessages[isSharingVideo ? 'leaveVideo' : 'joinVideo']), description: intl.formatMessage(intlMessages[isSharingVideo ? 'leaveVideo' : 'joinVideo']),
label: intl.formatMessage(intlMessages[isSharingVideo ? 'leaveVideo' : 'joinVideo']), label: intl.formatMessage(intlMessages[isSharingVideo ? 'leaveVideo' : 'joinVideo']),
disabled: isDisabled, disabled: isDisabled && !isSharingVideo,
click: isSharingVideo ? handleCloseVideo : handleJoinVideo, click: isSharingVideo ? handleCloseVideo : handleJoinVideo,
}, },
]; ];

View File

@ -19,12 +19,14 @@ const isDisabled = () => {
const videoSettings = Settings.dataSaving; const videoSettings = Settings.dataSaving;
const enableShare = videoSettings.viewParticipantsWebcams; const enableShare = videoSettings.viewParticipantsWebcams;
const lockCam = VideoService.isLocked(); const lockCam = VideoService.isLocked();
const webcamOnlyModerator = VideoService.webcamOnlyModerator();
const user = Users.findOne({ userId: Auth.userID }); const user = Users.findOne({ userId: Auth.userID });
const userLocked = mapUser(user).isLocked; const userLocked = mapUser(user).isLocked;
const isConnecting = (!isSharingVideo && isConnected); const isConnecting = (!isSharingVideo && isConnected);
const isLocked = (lockCam && userLocked) || webcamOnlyModerator;
const isLocked = (lockCam && userLocked);
return isLocked return isLocked
|| isWaitingResponse || isWaitingResponse

View File

@ -26,7 +26,7 @@ const mapUser = (user) => {
isMuted: voiceUser ? voiceUser.muted : false, isMuted: voiceUser ? voiceUser.muted : false,
isTalking: voiceUser ? voiceUser.talking : false, isTalking: voiceUser ? voiceUser.talking : false,
isListenOnly: voiceUser ? voiceUser.listenOnly : false, isListenOnly: voiceUser ? voiceUser.listenOnly : false,
isSharingWebcam: 0, isSharingWebcam: user.has_stream,
isPhoneUser: user.phone_user, isPhoneUser: user.phone_user,
isOnline: user.connectionStatus === 'online', isOnline: user.connectionStatus === 'online',
}; };