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-09 23:09:56 +08:00
|
|
|
const { presentationIsOpen, isResizing, cameraPosition, focusedCamera, presentationVideoRate, pushLayout } = m;
|
2021-06-10 00:50:31 +08:00
|
|
|
|
2022-03-23 02:29:49 +08:00
|
|
|
const defaultPayload = { presentationIsOpen, isResizing, cameraPosition, focusedCamera, presentationVideoRate, ...payload};
|
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}`);
|
|
|
|
}
|
|
|
|
}
|