bigbluebutton-Github/bigbluebutton-html5/imports/api/polls/server/methods/publishPoll.js

31 lines
964 B
JavaScript
Raw Normal View History

2018-09-25 06:43:54 +08:00
import RedisPubSub from '/imports/startup/server/redis';
import Polls from '/imports/api/polls';
2019-05-10 02:41:15 +08:00
import Logger from '/imports/startup/server/logger';
import { extractCredentials } from '/imports/api/common/server/helpers';
import { check } from 'meteor/check';
2018-09-25 06:43:54 +08:00
export default function publishPoll() {
2018-09-25 06:43:54 +08:00
const REDIS_CONFIG = Meteor.settings.private.redis;
const CHANNEL = REDIS_CONFIG.channels.toAkkaApps;
const EVENT_NAME = 'ShowPollResultReqMsg';
const { meetingId, requesterUserId } = extractCredentials(this.userId);
check(meetingId, String);
check(requesterUserId, String);
const poll = Polls.findOne({ meetingId }); // TODO--send pollid from client
2019-05-10 02:41:15 +08:00
if (!poll) {
Logger.error(`Attempted to publish inexisting poll for meetingId: ${meetingId}`);
return false;
}
2018-09-25 06:43:54 +08:00
return RedisPubSub.publishUserMessage(
CHANNEL,
EVENT_NAME,
meetingId,
2019-05-10 02:41:15 +08:00
requesterUserId,
2018-09-25 06:43:54 +08:00
({ requesterId: requesterUserId, pollId: poll.id }),
);
}