2020-06-04 00:29:44 +08:00
|
|
|
import Logger from '/imports/startup/server/logger';
|
|
|
|
import VideoStreams from '/imports/api/video-streams';
|
|
|
|
|
2023-03-20 20:23:39 +08:00
|
|
|
export default async function clearVideoStreams(meetingId) {
|
2020-06-04 00:29:44 +08:00
|
|
|
if (meetingId) {
|
2020-11-25 04:44:13 +08:00
|
|
|
try {
|
2023-03-20 20:23:39 +08:00
|
|
|
const numberAffected = await VideoStreams.removeAsync({ meetingId });
|
2020-11-25 04:44:13 +08:00
|
|
|
|
|
|
|
if (numberAffected) {
|
|
|
|
Logger.info(`Cleared VideoStreams in (${meetingId})`);
|
|
|
|
}
|
|
|
|
} catch (err) {
|
2020-12-02 04:02:50 +08:00
|
|
|
Logger.error(`Error on clearing VideoStreams (${meetingId}). ${err}`);
|
2020-11-25 04:44:13 +08:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
try {
|
2023-03-20 20:23:39 +08:00
|
|
|
const numberAffected = await VideoStreams.removeAsync({});
|
2020-06-04 00:29:44 +08:00
|
|
|
|
2020-11-25 04:44:13 +08:00
|
|
|
if (numberAffected) {
|
|
|
|
Logger.info('Cleared VideoStreams in all meetings');
|
|
|
|
}
|
|
|
|
} catch (err) {
|
|
|
|
Logger.error(`Error on clearing VideoStreams (all). ${err}`);
|
|
|
|
}
|
|
|
|
}
|
2020-06-04 00:29:44 +08:00
|
|
|
}
|