bigbluebutton-Github/bigbluebutton-html5/imports/api/breakouts/server/handlers/breakoutJoinURL.js

40 lines
870 B
JavaScript
Raw Normal View History

import { check } from 'meteor/check';
import Logger from '/imports/startup/server/logger';
import Breakouts from '/imports/api/breakouts';
export default function handleBreakoutJoinURL({ body }) {
2016-11-14 19:57:10 +08:00
const {
redirectToHtml5JoinURL,
userId,
breakoutId,
} = body;
2016-11-14 19:57:10 +08:00
check(redirectToHtml5JoinURL, String);
2016-11-15 00:12:54 +08:00
2016-11-14 19:57:10 +08:00
const selector = {
breakoutId,
2016-11-14 19:57:10 +08:00
};
2018-06-07 05:24:09 +08:00
const modifier = {
$push: {
users: {
userId,
redirectToHtml5JoinURL,
insertedTime: new Date().getTime(),
},
2018-06-07 05:24:09 +08:00
},
};
try {
const { insertedId, numberAffected } = Breakouts.upsert(selector, modifier);
2016-11-29 03:48:02 +08:00
2018-06-07 05:24:09 +08:00
if (insertedId) {
Logger.info(`Added breakout id=${breakoutId}`);
} else if (numberAffected) {
Logger.info(`Upserted breakout id=${breakoutId}`);
}
} catch (err) {
Logger.error(`Adding breakout to collection: ${err}`);
}
2016-11-14 19:57:10 +08:00
}