2019-08-01 03:10:41 +08:00
|
|
|
import { Slides, SlidePositions } from '/imports/api/slides';
|
2016-10-21 19:41:17 +08:00
|
|
|
import Logger from '/imports/startup/server/logger';
|
2016-05-13 01:43:59 +08:00
|
|
|
|
2016-11-12 03:02:46 +08:00
|
|
|
export default function clearSlides(meetingId) {
|
2016-10-21 19:41:17 +08:00
|
|
|
if (meetingId) {
|
2020-11-25 04:44:13 +08:00
|
|
|
try {
|
|
|
|
const numberAffectedSlidePositions = SlidePositions.remove({ meetingId });
|
2019-08-01 03:10:41 +08:00
|
|
|
|
2020-11-25 04:44:13 +08:00
|
|
|
const numberAffected = Slides.remove({ meetingId });
|
|
|
|
|
|
|
|
if (numberAffectedSlidePositions) {
|
|
|
|
Logger.info(`Cleared SlidePositions (${meetingId})`);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (numberAffected) {
|
|
|
|
Logger.info(`Cleared Slides (${meetingId})`);
|
|
|
|
}
|
|
|
|
} catch (err) {
|
|
|
|
Logger.error(`Error on cleaning Slides (${meetingId}). ${err}`);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
try {
|
|
|
|
const numberAffectedSlidePositions = SlidePositions.remove({ meetingId });
|
2016-11-18 20:28:55 +08:00
|
|
|
|
2020-11-25 04:44:13 +08:00
|
|
|
const numberAffected = Slides.remove({ meetingId });
|
2019-08-01 03:10:41 +08:00
|
|
|
|
2020-11-25 04:44:13 +08:00
|
|
|
if (numberAffectedSlidePositions) {
|
|
|
|
Logger.info(`Cleared SlidePositions (${meetingId})`);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (numberAffected) {
|
|
|
|
Logger.info('Cleared Slides (all)');
|
|
|
|
}
|
|
|
|
} catch (err) {
|
|
|
|
Logger.error(`Error on cleaning Slides (all). ${err}`);
|
|
|
|
}
|
|
|
|
}
|
2017-06-03 03:25:02 +08:00
|
|
|
}
|