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';
|
|
|
|
|
2022-02-05 02:03:39 +08:00
|
|
|
export default 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);
|
|
|
|
|
2022-02-18 03:33:41 +08:00
|
|
|
const m = LayoutMeetings.findOne({ 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,
|
|
|
|
cameraPosition: String,
|
|
|
|
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}`);
|
|
|
|
}
|
|
|
|
}
|