2017-10-12 10:00:28 +08:00
|
|
|
import Users from '/imports/api/users';
|
2017-10-26 01:29:03 +08:00
|
|
|
import changeRole from '/imports/api/users/server/modifiers/changeRole';
|
2017-10-12 09:02:23 +08:00
|
|
|
|
|
|
|
export default function handlePresenterAssigned({ body }, meetingId) {
|
2017-10-26 03:00:31 +08:00
|
|
|
const USER_CONFIG = Meteor.settings.public.user;
|
|
|
|
const ROLE_PRESENTER = USER_CONFIG.role_presenter;
|
|
|
|
|
2017-10-26 01:29:03 +08:00
|
|
|
const { presenterId, assignedBy } = body;
|
2017-10-12 09:02:23 +08:00
|
|
|
|
2017-10-26 03:00:31 +08:00
|
|
|
changeRole(ROLE_PRESENTER, true, presenterId, meetingId, assignedBy);
|
2017-02-23 02:59:47 +08:00
|
|
|
|
|
|
|
const selector = {
|
|
|
|
meetingId,
|
2017-10-26 01:29:03 +08:00
|
|
|
userId: { $ne: presenterId },
|
|
|
|
presenter: true,
|
2017-02-23 02:59:47 +08:00
|
|
|
};
|
|
|
|
|
2017-10-26 01:29:03 +08:00
|
|
|
const prevPresenter = Users.findOne(selector);
|
2017-10-26 23:13:43 +08:00
|
|
|
return changeRole(ROLE_PRESENTER, false, prevPresenter.userId, meetingId, assignedBy);
|
2017-10-12 09:02:23 +08:00
|
|
|
}
|