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';
|
2019-05-09 01:15:25 +08:00
|
|
|
import Logger from '/imports/startup/server/logger';
|
2017-07-22 03:34:28 +08:00
|
|
|
|
2021-03-09 03:45:09 +08:00
|
|
|
export default function handleMeetingEnd({ header, body }) {
|
2019-08-22 20:05:06 +08:00
|
|
|
check(body, Object);
|
|
|
|
const { meetingId } = body;
|
2017-07-22 03:34:28 +08:00
|
|
|
check(meetingId, String);
|
|
|
|
|
2021-03-09 03:45:09 +08:00
|
|
|
check(header, Object);
|
|
|
|
const { userId } = header;
|
|
|
|
check(userId, String);
|
|
|
|
|
2019-05-09 03:15:17 +08:00
|
|
|
const cb = (err, num, meetingType) => {
|
2019-05-09 01:15:25 +08:00
|
|
|
if (err) {
|
2019-08-31 02:43:48 +08:00
|
|
|
Logger.error(`${meetingType} ending error: ${err}`);
|
2019-05-09 01:15:25 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (num) {
|
|
|
|
Meteor.setTimeout(() => { meetingHasEnded(meetingId); }, 10000);
|
|
|
|
}
|
2019-04-27 01:13:45 +08:00
|
|
|
};
|
|
|
|
|
2019-08-31 02:43:48 +08:00
|
|
|
Meetings.update({ meetingId },
|
2021-03-09 03:45:09 +08:00
|
|
|
{ $set: { meetingEnded: true, meetingEndedBy: userId } },
|
2019-08-31 02:43:48 +08:00
|
|
|
(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
|
|
|
}
|