bigbluebutton-Github/bigbluebutton-html5/imports/api/users/server/handlers/presenterAssigned.js
2017-10-25 12:00:31 -07:00

22 lines
678 B
JavaScript

import { Meteor } from 'meteor/meteor';
import Users from '/imports/api/users';
import changeRole from '/imports/api/users/server/modifiers/changeRole';
export default function handlePresenterAssigned({ body }, meetingId) {
const USER_CONFIG = Meteor.settings.public.user;
const ROLE_PRESENTER = USER_CONFIG.role_presenter;
const { presenterId, assignedBy } = body;
changeRole(ROLE_PRESENTER, true, presenterId, meetingId, assignedBy);
const selector = {
meetingId,
userId: { $ne: presenterId },
presenter: true,
};
const prevPresenter = Users.findOne(selector);
changeRole(ROLE_PRESENTER, false, prevPresenter.userId, meetingId, assignedBy);
}