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

40 lines
1.5 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';
import { Presentations, Slides } from '/imports/startup/collections';
import { redisConfig } from '/config';
2016-04-20 01:43:31 +08:00
Meteor.methods({
publishSwitchToPreviousSlideMessage(meetingId, userId, authToken) {
let currentPresentationDoc, currentSlideDoc, message, previousSlideDoc;
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
previousSlideDoc = Slides.findOne({
2016-04-20 01:43:31 +08:00
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-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
});