bigbluebutton-Github/bigbluebutton-html5/imports/api/meetings/server/handlers/meetingEnd.js

57 lines
1.4 KiB
JavaScript
Raw Normal View History

2017-07-22 03:34:28 +08:00
import { check } from 'meteor/check';
2019-04-06 02:10:05 +08:00
import meetingHasEnded from '../modifiers/meetingHasEnded';
2019-03-20 04:06:13 +08:00
import Meetings from '/imports/api/meetings';
import Breakouts from '/imports/api/breakouts';
import Logger from '/imports/startup/server/logger';
2017-07-22 03:34:28 +08:00
export default async function handleMeetingEnd({ header, body }) {
check(body, Object);
2021-07-08 22:51:00 +08:00
const { meetingId, reason } = body;
2017-07-22 03:34:28 +08:00
check(meetingId, String);
check(header, Object);
const { userId } = header;
check(userId, String);
const cb = (err, num, meetingType) => {
if (err) {
Logger.error(`${meetingType} ending error: ${err}`);
return;
}
if (num) {
Meteor.setTimeout(() => { meetingHasEnded(meetingId); }, 10000);
}
2019-04-27 01:13:45 +08:00
};
await Meetings.find({ meetingId }).forEachAsync(async (doc) => {
let num = 0;
let err = null;
try {
num = await Meetings.updateAsync({ meetingId },
{
$set: {
meetingEnded: true,
meetingEndedBy: userId,
meetingEndedReason: reason,
learningDashboardAccessToken: doc.password.learningDashboardAccessToken,
},
});
} catch (error) {
err = error;
}
cb(err, num, 'Meeting');
});
let num = 0;
let err = null;
try {
num = await Breakouts.update(
{ parentMeetingId: meetingId },
{ $set: { meetingEnded: true } },
);
} catch (error) {
err = error;
}
cb(err, num, 'Breakout');
2017-07-22 03:34:28 +08:00
}