Fix presenter assigned message handle

This commit is contained in:
Klaus 2017-06-28 13:44:11 -03:00
parent 83cbb47195
commit 894fd70e68

View File

@ -4,14 +4,14 @@ import Users from './../../';
export default function handlePresenterAssigned({ body, header }) { export default function handlePresenterAssigned({ body, header }) {
const { meetingId } = header; const { meetingId } = header;
const { intId } = body; const { presenterId } = body;
check(meetingId, String); check(meetingId, String);
check(intId, String); check(presenterId, String);
const selector = { const selector = {
meetingId, meetingId,
userId: intId, userId: presenterId,
}; };
const modifier = { const modifier = {
@ -26,18 +26,18 @@ export default function handlePresenterAssigned({ body, header }) {
} }
if (numChanged) { if (numChanged) {
unassignCurrentPresenter(meetingId, intId); unassignCurrentPresenter(meetingId, presenterId);
return Logger.info(`Assigned user as presenter id=${intId} meeting=${meetingId}`); return Logger.info(`Assigned user as presenter id=${presenterId} meeting=${meetingId}`);
} }
}; };
return Users.update(selector, modifier, cb); return Users.update(selector, modifier, cb);
} }
const unassignCurrentPresenter = (meetingId, intId) => { const unassignCurrentPresenter = (meetingId, presenterId) => {
const selector = { const selector = {
meetingId, meetingId,
userId: { $ne: intId }, userId: { $ne: presenterId },
'user.presenter': true, 'user.presenter': true,
}; };