2016-05-05 04:25:34 +08:00
|
|
|
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-05-10 05:19:45 +08:00
|
|
|
import { Presentations, Slides } from '/imports/startup/collections';
|
2016-04-29 06:01:43 +08:00
|
|
|
import { redisConfig } from '/config';
|
2016-04-28 05:04:15 +08:00
|
|
|
|
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);
|
2016-04-29 06:01:43 +08:00
|
|
|
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
|
|
|
});
|