2018-08-16 19:20:02 +08:00
|
|
|
import Presentations from '/imports/api/presentations';
|
2019-08-01 03:10:41 +08:00
|
|
|
import { Slides } from '/imports/api/slides';
|
2018-08-16 19:20:02 +08:00
|
|
|
import { Meteor } from 'meteor/meteor';
|
|
|
|
import RedisPubSub from '/imports/startup/server/redis';
|
2020-02-07 04:47:28 +08:00
|
|
|
import { extractCredentials } from '/imports/api/common/server/helpers';
|
2021-03-17 00:15:41 +08:00
|
|
|
import { check } from 'meteor/check';
|
2021-05-06 00:17:26 +08:00
|
|
|
import Logger from '/imports/startup/server/logger';
|
2018-08-16 19:20:02 +08:00
|
|
|
|
2022-08-16 20:12:43 +08:00
|
|
|
export default function zoomSlide(slideNumber, podId, widthRatio, heightRatio, x, y) {
|
2018-08-16 19:20:02 +08:00
|
|
|
const REDIS_CONFIG = Meteor.settings.private.redis;
|
|
|
|
const CHANNEL = REDIS_CONFIG.channels.toAkkaApps;
|
|
|
|
const EVENT_NAME = 'ResizeAndMovePagePubMsg';
|
2021-03-17 00:15:41 +08:00
|
|
|
|
2021-05-06 00:17:26 +08:00
|
|
|
try {
|
|
|
|
const { meetingId, requesterUserId } = extractCredentials(this.userId);
|
|
|
|
|
|
|
|
check(meetingId, String);
|
|
|
|
check(requesterUserId, String);
|
2023-01-27 23:49:32 +08:00
|
|
|
check(slideNumber, Number);
|
|
|
|
check(podId, String);
|
|
|
|
check(widthRatio, Number);
|
|
|
|
check(heightRatio, Number);
|
|
|
|
check(x, Number);
|
|
|
|
check(y, Number);
|
2021-05-06 00:17:26 +08:00
|
|
|
|
|
|
|
const selector = {
|
|
|
|
meetingId,
|
|
|
|
podId,
|
|
|
|
current: true,
|
|
|
|
};
|
|
|
|
const Presentation = Presentations.findOne(selector);
|
|
|
|
|
|
|
|
if (!Presentation) {
|
|
|
|
throw new Meteor.Error('presentation-not-found', 'You need a presentation to be able to switch slides');
|
|
|
|
}
|
|
|
|
|
|
|
|
const Slide = Slides.findOne({
|
|
|
|
meetingId,
|
|
|
|
podId,
|
|
|
|
presentationId: Presentation.id,
|
|
|
|
num: slideNumber,
|
|
|
|
});
|
|
|
|
|
|
|
|
if (!Slide) {
|
|
|
|
throw new Meteor.Error('slide-not-found', `Slide number ${slideNumber} not found in the current presentation`);
|
|
|
|
}
|
|
|
|
|
|
|
|
const payload = {
|
|
|
|
podId,
|
|
|
|
presentationId: Presentation.id,
|
|
|
|
pageId: Slide.id,
|
2022-08-16 20:12:43 +08:00
|
|
|
xOffset: x,
|
|
|
|
yOffset: y,
|
|
|
|
widthRatio,
|
|
|
|
heightRatio,
|
2021-05-06 00:17:26 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
RedisPubSub.publishUserMessage(CHANNEL, EVENT_NAME, meetingId, requesterUserId, payload);
|
|
|
|
} catch (err) {
|
|
|
|
Logger.error(`Exception while invoking method zoomSlide ${err.stack}`);
|
2018-08-16 19:20:02 +08:00
|
|
|
}
|
|
|
|
}
|