2018-04-06 06:29:58 +08:00
|
|
|
import { check } from 'meteor/check';
|
|
|
|
import PresentationPods from '/imports/api/presentation-pods';
|
|
|
|
import removePresentationPod from '../modifiers/removePresentationPod';
|
|
|
|
import addPresentationPod from '../modifiers/addPresentationPod';
|
|
|
|
|
2023-03-15 03:50:35 +08:00
|
|
|
export default async function handleSyncGetPresentationPods({ body }, meetingId) {
|
2018-04-06 06:29:58 +08:00
|
|
|
check(body, Object);
|
|
|
|
check(meetingId, String);
|
|
|
|
|
|
|
|
const { pods } = body;
|
|
|
|
check(pods, Array);
|
|
|
|
|
2023-03-15 03:50:35 +08:00
|
|
|
const presentationPodIds = pods.map((pod) => pod.id);
|
2018-04-06 06:29:58 +08:00
|
|
|
|
2023-03-15 03:50:35 +08:00
|
|
|
const presentationPodsToRemove = await PresentationPods.find({
|
2018-04-06 06:29:58 +08:00
|
|
|
meetingId,
|
|
|
|
podId: { $nin: presentationPodIds },
|
2023-03-15 03:50:35 +08:00
|
|
|
}, { fields: { podId: 1 } }).fetchAsync();
|
2018-04-06 06:29:58 +08:00
|
|
|
|
2023-03-15 03:50:35 +08:00
|
|
|
presentationPodsToRemove.forEach(async (p) => removePresentationPod(meetingId, p.podId));
|
2018-04-06 06:29:58 +08:00
|
|
|
|
2023-03-15 03:50:35 +08:00
|
|
|
pods.forEach(async (pod) => {
|
2018-04-10 03:48:37 +08:00
|
|
|
// 'podId' and 'currentPresenterId' for some reason called 'id' and 'currentPresenter'
|
|
|
|
// in this message
|
2018-04-06 06:29:58 +08:00
|
|
|
const {
|
|
|
|
id: podId,
|
|
|
|
currentPresenter: currentPresenterId,
|
|
|
|
presentations,
|
|
|
|
} = pod;
|
2023-03-15 03:50:35 +08:00
|
|
|
await addPresentationPod(meetingId, { podId, currentPresenterId }, presentations);
|
2018-04-06 06:29:58 +08:00
|
|
|
});
|
|
|
|
}
|