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);
|
2021-07-08 22:51:00 +08:00
|
|
|
const { meetingId, reason } = 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
|
|
|
};
|
|
|
|
|
2021-10-15 01:00:25 +08:00
|
|
|
Meetings.find({ meetingId }).forEach((doc) => {
|
|
|
|
Meetings.update({ meetingId },
|
|
|
|
{
|
|
|
|
$set: {
|
|
|
|
meetingEnded: true,
|
|
|
|
meetingEndedBy: userId,
|
|
|
|
meetingEndedReason: reason,
|
|
|
|
learningDashboardAccessToken: doc.password.learningDashboardAccessToken,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
(err, num) => { cb(err, num, 'Meeting'); });
|
|
|
|
});
|
2019-08-31 02:43:48 +08:00
|
|
|
|
|
|
|
Breakouts.update({ parentMeetingId: meetingId },
|
|
|
|
{ $set: { meetingEnded: true } },
|
|
|
|
(err, num) => { cb(err, num, 'Breakout'); });
|
2017-07-22 03:34:28 +08:00
|
|
|
}
|