bigbluebutton-Github/bigbluebutton-html5/imports/startup/server/meteorMethods/publishSwitchToNextSlideMessage.js

40 lines
1.4 KiB
JavaScript
Raw Normal View History

import { publish } from '/imports/startup/server/helpers';
import { isAllowedTo } from '/imports/startup/server/userPermissions';
2016-05-05 02:29:43 +08:00
import { appendMessageHeader } from '/imports/startup/server/helpers';
2016-04-29 05:10:43 +08:00
import { Presentations, Slides } from '/collections/collections';
import { redisConfig } from '/config';
2016-04-29 05:10:43 +08:00
2016-04-20 01:43:31 +08:00
Meteor.methods({
publishSwitchToNextSlideMessage(meetingId, userId, authToken) {
let currentPresentationDoc, currentSlideDoc, message, nextSlideDoc;
2016-04-29 05:10:43 +08:00
currentPresentationDoc = Presentations.findOne({
2016-04-20 01:43:31 +08:00
meetingId: meetingId,
'presentation.current': true,
});
if (currentPresentationDoc != null) {
2016-04-29 05:10:43 +08:00
currentSlideDoc = Slides.findOne({
2016-04-20 01:43:31 +08:00
meetingId: meetingId,
presentationId: currentPresentationDoc.presentation.id,
'slide.current': true,
});
if (currentSlideDoc != null) {
2016-04-29 05:10:43 +08:00
nextSlideDoc = Slides.findOne({
2016-04-20 01:43:31 +08:00
meetingId: meetingId,
presentationId: currentPresentationDoc.presentation.id,
'slide.num': currentSlideDoc.slide.num + 1,
});
if ((nextSlideDoc != null) && isAllowedTo('switchSlide', meetingId, userId, authToken)) {
message = {
payload: {
page: nextSlideDoc.slide.id,
meeting_id: meetingId,
2016-05-05 05:49:01 +08:00
},
2016-04-20 01:43:31 +08:00
};
2016-04-20 05:16:32 +08:00
message = appendMessageHeader('go_to_slide', message);
return publish(redisConfig.channels.toBBBApps.presentation, message);
2016-04-20 01:43:31 +08:00
}
}
}
2016-05-05 05:49:01 +08:00
},
2016-04-20 01:43:31 +08:00
});