2021-06-10 00:50:31 +08:00
|
|
|
import Logger from '/imports/startup/server/logger';
|
2022-02-05 02:03:39 +08:00
|
|
|
import { LayoutMeetings } from '/imports/api/meetings';
|
2021-07-19 22:02:58 +08:00
|
|
|
import RedisPubSub from '/imports/startup/server/redis';
|
2021-06-10 00:50:31 +08:00
|
|
|
import { extractCredentials } from '/imports/api/common/server/helpers';
|
|
|
|
import { check } from 'meteor/check';
|
|
|
|
|
2023-03-14 00:59:52 +08:00
|
|
|
export default async function changeLayout(payload) {
|
2021-07-19 22:02:58 +08:00
|
|
|
const REDIS_CONFIG = Meteor.settings.private.redis;
|
|
|
|
const CHANNEL = REDIS_CONFIG.channels.toAkkaApps;
|
|
|
|
const EVENT_NAME = 'BroadcastLayoutMsg';
|
|
|
|
|
2021-06-10 00:50:31 +08:00
|
|
|
try {
|
|
|
|
const { meetingId, requesterUserId } = extractCredentials(this.userId);
|
|
|
|
|
|
|
|
check(meetingId, String);
|
|
|
|
check(requesterUserId, String);
|
|
|
|
|
2023-03-14 00:59:52 +08:00
|
|
|
const m = await LayoutMeetings.findOneAsync({ meetingId }) || {};
|
2022-03-17 01:12:11 +08:00
|
|
|
const {
|
|
|
|
layout,
|
|
|
|
pushLayout,
|
|
|
|
presentationIsOpen,
|
|
|
|
isResizing,
|
|
|
|
cameraPosition,
|
|
|
|
focusedCamera,
|
|
|
|
presentationVideoRate,
|
|
|
|
} = m;
|
2021-06-10 00:50:31 +08:00
|
|
|
|
2022-03-17 01:12:11 +08:00
|
|
|
const defaultPayload = {
|
|
|
|
layout,
|
|
|
|
pushLayout,
|
|
|
|
presentationIsOpen,
|
|
|
|
isResizing,
|
|
|
|
cameraPosition,
|
|
|
|
focusedCamera,
|
|
|
|
presentationVideoRate,
|
|
|
|
...payload,
|
|
|
|
};
|
|
|
|
|
|
|
|
check(defaultPayload, {
|
|
|
|
layout: String,
|
|
|
|
pushLayout: Boolean,
|
|
|
|
presentationIsOpen: Boolean,
|
|
|
|
isResizing: Boolean,
|
2023-03-29 22:02:14 +08:00
|
|
|
cameraPosition: Match.Maybe(String),
|
2022-03-17 01:12:11 +08:00
|
|
|
focusedCamera: String,
|
|
|
|
presentationVideoRate: Number,
|
|
|
|
});
|
2022-02-05 02:03:39 +08:00
|
|
|
|
|
|
|
RedisPubSub.publishUserMessage(CHANNEL, EVENT_NAME, meetingId, requesterUserId, defaultPayload);
|
2021-06-10 00:50:31 +08:00
|
|
|
} catch (err) {
|
|
|
|
Logger.error(`Exception while invoking method changeLayout ${err.stack}`);
|
|
|
|
}
|
|
|
|
}
|