bigbluebutton-Github/bigbluebutton-html5/server/methods/publishSwitchToPreviousSlideMessage.js

38 lines
1.3 KiB
JavaScript
Raw Normal View History

import { publish } from '/server/redispubsub';
import { isAllowedTo } from '/server/user_permissions';
import { appendMessageHeader } from '/server/helpers';
2016-04-20 01:43:31 +08:00
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,
2016-04-20 05:16:32 +08:00
}
2016-04-20 01:43:31 +08:00
};
2016-04-20 05:16:32 +08:00
message = appendMessageHeader('go_to_slide', message);
2016-04-20 01:43:31 +08:00
return publish(Meteor.config.redis.channels.toBBBApps.presentation, message);
}
}
}
}
});