bigbluebutton-Github/bigbluebutton-html5/imports/api/slides/server/modifiers/addSlidePositions.js

56 lines
1.2 KiB
JavaScript
Raw Normal View History

import { SlidePositions } from '/imports/api/slides';
import Logger from '/imports/startup/server/logger';
import { check } from 'meteor/check';
import flat from 'flat';
export default function addSlidePositions(
meetingId,
podId,
presentationId,
slideId,
slidePosition,
) {
check(meetingId, String);
check(podId, String);
check(presentationId, String);
check(slideId, String);
check(slidePosition, {
width: Number,
height: Number,
xCamera: Number,
yCamera: Number,
2022-05-12 05:58:16 +08:00
zoom: Number,
});
const selector = {
meetingId,
podId,
presentationId,
id: slideId,
};
const modifier = {
$set: Object.assign(
{ meetingId },
{ podId },
{ presentationId },
{ id: slideId },
flat(slidePosition),
{ safe: true },
),
};
try {
const { insertedId } = SlidePositions.upsert(selector, modifier);
if (insertedId) {
Logger.info(`Added slide position id=${slideId} pod=${podId} presentation=${presentationId}`);
} else {
Logger.info(`Upserted slide position id=${slideId} pod=${podId} presentation=${presentationId}`);
}
} catch (err) {
Logger.error(`Adding slide position to collection: ${err}`);
}
}