2017-10-12 10:00:28 +08:00
|
|
|
import RedisPubSub from '/imports/startup/server/redis';
|
2017-09-29 21:29:55 +08:00
|
|
|
import { check } from 'meteor/check';
|
2017-10-12 10:00:28 +08:00
|
|
|
import Presentations from '/imports/api/presentations';
|
2017-09-29 21:29:55 +08:00
|
|
|
|
|
|
|
export default function setPresentation(credentials, presentationId) {
|
|
|
|
const REDIS_CONFIG = Meteor.settings.redis;
|
|
|
|
const CHANNEL = REDIS_CONFIG.channels.toAkkaApps;
|
|
|
|
const EVENT_NAME = 'SetCurrentPresentationPubMsg';
|
|
|
|
|
|
|
|
const { meetingId, requesterUserId } = credentials;
|
|
|
|
|
|
|
|
check(meetingId, String);
|
|
|
|
check(requesterUserId, String);
|
|
|
|
check(presentationId, String);
|
|
|
|
|
|
|
|
const currentPresentation = Presentations.findOne({
|
|
|
|
meetingId,
|
|
|
|
id: presentationId,
|
|
|
|
current: true,
|
|
|
|
});
|
|
|
|
|
|
|
|
if (currentPresentation && currentPresentation.id === presentationId) {
|
|
|
|
return Promise.resolve();
|
|
|
|
}
|
|
|
|
|
|
|
|
const payload = {
|
|
|
|
presentationId,
|
|
|
|
};
|
|
|
|
|
|
|
|
return RedisPubSub.publishUserMessage(CHANNEL, EVENT_NAME, meetingId, requesterUserId, payload);
|
|
|
|
}
|