Merge pull request #6930 from Tainan404/issue-6919

Fix few breakout  room bugs.
This commit is contained in:
Anton Georgiev 2019-03-14 13:05:54 -04:00 committed by GitHub
commit 5fe8d6a2c0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 49 additions and 21 deletions

View File

@ -1,8 +1,9 @@
import { Meteor } from 'meteor/meteor';
import Breakouts from '/imports/api/breakouts';
import Users from '/imports/api/users';
import Logger from '/imports/startup/server/logger';
function breakouts(credentials, moderator) {
function breakouts(credentials, moderator = false) {
const {
meetingId,
requesterUserId,
@ -10,14 +11,17 @@ function breakouts(credentials, moderator) {
Logger.debug(`Publishing Breakouts for ${meetingId} ${requesterUserId}`);
if (moderator) {
const presenterSelector = {
$or: [
{ parentMeetingId: meetingId },
{ breakoutId: meetingId },
],
};
const User = Users.findOne({ userId: requesterUserId });
if (!!User && User.moderator) {
const presenterSelector = {
$or: [
{ parentMeetingId: meetingId },
{ breakoutId: meetingId },
],
};
return Breakouts.find(presenterSelector);
return Breakouts.find(presenterSelector);
}
}
const selector = {

View File

@ -1,9 +1,10 @@
import { Meteor } from 'meteor/meteor';
import { check } from 'meteor/check';
import Meetings from '/imports/api/meetings';
import Users from '/imports/api/users';
import Logger from '/imports/startup/server/logger';
function meetings(credentials) {
function meetings(credentials, isModerator = false) {
const { meetingId, requesterUserId, requesterToken } = credentials;
check(meetingId, String);
@ -15,13 +16,19 @@ function meetings(credentials) {
const selector = {
$or: [
{ meetingId },
{
'meetingProp.isBreakout': true,
'breakoutProps.parentId': meetingId,
},
],
};
if (isModerator) {
const User = Users.findOne({ userId: requesterUserId });
if (!!User && User.moderator) {
selector.$or.push({
'meetingProp.isBreakout': true,
'breakoutProps.parentId': meetingId,
});
}
}
const options = {
fields: {
password: false,

View File

@ -57,11 +57,14 @@ function users(credentials, isModerator = false) {
};
if (isModerator) {
selector.$or.push({
'breakoutProps.isBreakoutUser': true,
'breakoutProps.parentId': meetingId,
connectionStatus: 'online',
});
const User = Users.findOne({ userId: requesterUserId });
if (!!User && User.moderator) {
selector.$or.push({
'breakoutProps.isBreakoutUser': true,
'breakoutProps.parentId': meetingId,
connectionStatus: 'online',
});
}
}
const options = {

View File

@ -201,6 +201,7 @@ const BaseContainer = withTracker(() => {
const { credentials, loggedIn } = Auth;
const { meetingId, requesterUserId } = credentials;
let breakoutRoomSubscriptionHandler;
let meetingModeratorSubscriptionHandler;
let userSubscriptionHandler;
const subscriptionErrorHandler = {
@ -238,6 +239,7 @@ const BaseContainer = withTracker(() => {
// override meteor subscription to verify if is moderator
userSubscriptionHandler = Meteor.subscribe('users', credentials, mappedUser.isModerator, subscriptionErrorHandler);
breakoutRoomSubscriptionHandler = Meteor.subscribe('breakouts', credentials, mappedUser.isModerator, subscriptionErrorHandler);
breakoutRoomSubscriptionHandler = Meteor.subscribe('meetings', credentials, mappedUser.isModerator, subscriptionErrorHandler);
}
const annotationsHandler = Meteor.subscribe('annotations', credentials, {
@ -265,6 +267,7 @@ const BaseContainer = withTracker(() => {
groupChatMessageHandler,
userSubscriptionHandler,
breakoutRoomSubscriptionHandler,
meetingModeratorSubscriptionHandler,
animations,
meetingExist: !!Meetings.find({ meetingId }).count(),
User,

View File

@ -98,7 +98,11 @@ class BreakoutRoom extends Component {
const hasUser = breakoutRoomUser(breakoutId);
if (!hasUser && !waiting) {
this.setState(
{ waiting: true, requestedBreakoutId: breakoutId },
{
waiting: true,
requestedBreakoutId: breakoutId,
generated: false,
},
() => requestJoinURL(breakoutId),
);
}

View File

@ -161,12 +161,19 @@ class NavBar extends PureComponent {
}
breakouts.forEach((breakout) => {
const userOnMeeting = breakout.users.filter(u => u.userId === Auth.userID).length;
if (breakout.freeJoin
&& !didSendBreakoutInvite
&& !userOnMeeting
&& !isBreakoutRoom) {
this.inviteUserToBreakout(breakout);
this.setState({ didSendBreakoutInvite: true });
}
if (!breakout.users) {
return;
}
const userOnMeeting = breakout.users.filter(u => u.userId === Auth.userID).length;
if (!userOnMeeting) return;
if ((!didSendBreakoutInvite && !isBreakoutRoom) ) {