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

34 lines
1.0 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 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
};
Meetings.update({ meetingId },
2021-07-08 22:51:00 +08:00
{ $set: { meetingEnded: true, meetingEndedBy: userId, meetingEndedReason: reason } },
(err, num) => { cb(err, num, 'Meeting'); });
Breakouts.update({ parentMeetingId: meetingId },
{ $set: { meetingEnded: true } },
(err, num) => { cb(err, num, 'Breakout'); });
2017-07-22 03:34:28 +08:00
}