Merge pull request #6270 from jfsiebel/html5-set-presenter-default-pod

Set HTML5 client as presenter in default pod
This commit is contained in:
Anton Georgiev 2018-11-22 14:24:41 -02:00 committed by GitHub
commit ec3aa585ce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,10 +1,13 @@
import Users from '/imports/api/users';
import PresentationPods from '/imports/api/presentation-pods';
import changeRole from '/imports/api/users/server/modifiers/changeRole';
import assignPresenter from '../methods/assignPresenter';
export default function handlePresenterAssigned({ body }, meetingId) {
export default function handlePresenterAssigned(credentials, meetingId) {
const USER_CONFIG = Meteor.settings.public.user;
const ROLE_PRESENTER = USER_CONFIG.role_presenter;
const { body } = credentials;
const { presenterId, assignedBy } = body;
changeRole(ROLE_PRESENTER, true, presenterId, meetingId, assignedBy);
@ -15,11 +18,34 @@ export default function handlePresenterAssigned({ body }, meetingId) {
presenter: true,
};
const defaultPodSelector = {
podId: 'DEFAULT_PRESENTATION_POD',
};
const prevPresenter = Users.findOne(selector);
// no previous presenters
// The below code is responsible for set Meeting presenter to be default pod presenter as well.
// It's been handled here because right now akka-apps don't handle all cases scenarios.
if (!prevPresenter) {
return true;
const currentDefaultPodPresenter = PresentationPods.findOne(defaultPodSelector);
const { currentPresenterId } = currentDefaultPodPresenter;
const podPresenterCredentials = {
meetingId,
requesterUserId: assignedBy,
};
if (currentDefaultPodPresenter.currentPresenterId !== '') {
const oldPresenter = Users.findOne({ userId: currentPresenterId });
if (oldPresenter.connectionStatus === 'offline') {
return assignPresenter(podPresenterCredentials, presenterId);
}
return true;
}
return assignPresenter(podPresenterCredentials, presenterId);
}
return changeRole(ROLE_PRESENTER, false, prevPresenter.userId, meetingId, assignedBy);