bigbluebutton-Github/bigbluebutton-html5/imports/api/2.0/slides/server/methods/switchSlide.js

50 lines
1.3 KiB
JavaScript
Raw Normal View History

2017-06-29 03:05:50 +08:00
import Presentations from '/imports/api/2.0/presentations';
import Slides from '/imports/api/2.0/slides';
import { Meteor } from 'meteor/meteor';
import { check } from 'meteor/check';
2017-07-01 03:16:00 +08:00
import RedisPubSub from '/imports/startup/server/redis2x';
2017-06-29 03:05:50 +08:00
export default function switchSlide(credentials, slideNumber) {
const REDIS_CONFIG = Meteor.settings.redis;
2017-07-25 01:50:44 +08:00
const CHANNEL = REDIS_CONFIG.channels.toAkkaApps;
const EVENT_NAME = 'SetCurrentPagePubMsg';
2017-06-29 03:05:50 +08:00
const { meetingId, requesterUserId, requesterToken } = credentials;
check(meetingId, String);
check(requesterUserId, String);
check(requesterToken, String);
check(slideNumber, Number);
2017-07-25 02:46:53 +08:00
const selector = {
2017-06-29 03:05:50 +08:00
meetingId,
2017-07-25 02:46:53 +08:00
current: true,
};
const Presentation = Presentations.findOne(selector);
2017-06-29 03:05:50 +08:00
if (!Presentation) {
throw new Meteor.Error(
'presentation-not-found', 'You need a presentation to be able to switch slides');
}
const Slide = Slides.findOne({
meetingId,
2017-07-25 02:46:53 +08:00
presentationId: Presentation.id,
num: slideNumber,
2017-06-29 03:05:50 +08:00
});
if (!Slide) {
throw new Meteor.Error(
'slide-not-found', `Slide number ${slideNumber} not found in the current presentation`);
}
const payload = {
2017-07-25 01:50:44 +08:00
pageId: Slide.id,
2017-07-25 02:46:53 +08:00
presentationId: Presentation.id,
2017-06-29 03:05:50 +08:00
};
2017-09-12 23:52:02 +08:00
return RedisPubSub.publishUserMessage(CHANNEL, EVENT_NAME, meetingId, requesterUserId, payload);
2017-09-08 00:47:20 +08:00
}