bigbluebutton-Github/bigbluebutton-html5/imports/api/users/server/handlers/presenterAssigned.js
2017-10-26 08:13:43 -07:00

21 lines
645 B
JavaScript

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);
return changeRole(ROLE_PRESENTER, false, prevPresenter.userId, meetingId, assignedBy);
}