bigbluebutton-Github/bigbluebutton-html5/server/methods/publishSwitchToPreviousSlideMessage.js
2016-04-27 21:04:15 +00:00

38 lines
1.3 KiB
JavaScript

import { publish } from '/server/redispubsub';
import { isAllowedTo } from '/server/user_permissions';
import { appendMessageHeader } from '/server/helpers';
Meteor.methods({
publishSwitchToPreviousSlideMessage(meetingId, userId, authToken) {
let currentPresentationDoc, currentSlideDoc, message, previousSlideDoc;
currentPresentationDoc = Meteor.Presentations.findOne({
meetingId: meetingId,
'presentation.current': true,
});
if (currentPresentationDoc != null) {
currentSlideDoc = Meteor.Slides.findOne({
meetingId: meetingId,
presentationId: currentPresentationDoc.presentation.id,
'slide.current': true,
});
if (currentSlideDoc != null) {
previousSlideDoc = Meteor.Slides.findOne({
meetingId: meetingId,
presentationId: currentPresentationDoc.presentation.id,
'slide.num': currentSlideDoc.slide.num - 1,
});
if ((previousSlideDoc != null) && isAllowedTo('switchSlide', meetingId, userId, authToken)) {
message = {
payload: {
page: previousSlideDoc.slide.id,
meeting_id: meetingId,
}
};
message = appendMessageHeader('go_to_slide', message);
return publish(Meteor.config.redis.channels.toBBBApps.presentation, message);
}
}
}
}
});