bigbluebutton-Github/bigbluebutton-html5/imports/api/meetings/server/modifiers/changeLayout.js
2023-03-20 16:24:41 -03:00

49 lines
1.2 KiB
JavaScript

import Logger from '/imports/startup/server/logger';
import { LayoutMeetings } from '/imports/api/meetings';
import { check } from 'meteor/check';
import { LAYOUT_TYPE } from '/imports/ui/components/layout/enums';
export default async function changeLayout(
meetingId,
layout,
presentationIsOpen,
isResizing,
cameraPosition,
focusedCamera,
presentationVideoRate,
pushLayout,
requesterUserId,
) {
try {
check(meetingId, String);
check(requesterUserId, String);
check(isResizing, Boolean);
check(layout, String);
const selector = {
meetingId,
};
const modifier = {
$set: {
layout: LAYOUT_TYPE[layout] || LAYOUT_TYPE.SMART_LAYOUT,
layoutUpdatedAt: new Date().getTime(),
presentationIsOpen,
isResizing,
cameraPosition,
focusedCamera,
presentationVideoRate,
pushLayout,
},
};
const numberAffected = LayoutMeetings.updateAsync(selector, modifier);
if (numberAffected) {
Logger.info(`MeetingLayout changed to ${layout} for meeting=${meetingId} requested by user=${requesterUserId}`);
}
} catch (err) {
Logger.error(`Exception while invoking method changeLayout ${err.stack}`);
}
}