bigbluebutton-Github/bigbluebutton-html5/imports/api/breakouts/server/handlers/breakoutJoinURL.js
2019-02-18 09:44:14 -03:00

45 lines
918 B
JavaScript

import { check } from 'meteor/check';
import Logger from '/imports/startup/server/logger';
import Breakouts from '/imports/api/breakouts';
export default function handleBreakoutJoinURL({ body }) {
const {
redirectToHtml5JoinURL,
userId,
breakoutId,
} = body;
check(redirectToHtml5JoinURL, String);
const selector = {
breakoutId,
};
const modifier = {
$push: {
users: {
userId,
redirectToHtml5JoinURL,
insertedTime: new Date().getTime(),
},
},
};
const cb = (cbErr, numChanged) => {
if (cbErr) {
return Logger.error(`Adding breakout to collection: ${cbErr}`);
}
const {
insertedId,
} = numChanged;
if (insertedId) {
return Logger.info(`Added breakout id=${breakoutId}`);
}
return Logger.info(`Upserted breakout id=${breakoutId}`);
};
return Breakouts.upsert(selector, modifier, cb);
}