bigbluebutton-Github/bigbluebutton-html5/imports/api/polls/server/methods/startPoll.js
tibroc 13ae19bc3d Use currentPoll instead of state to determine if live results should be rendered
To avoid re-rendering of the poll answers when the poll panel is opened and closed,
this commit uses the currentPoll object to determine wether results should be rendered.
2021-06-07 10:56:14 +02:00

39 lines
1.2 KiB
JavaScript

import RedisPubSub from '/imports/startup/server/redis';
import { check } from 'meteor/check';
import { extractCredentials } from '/imports/api/common/server/helpers';
import Logger from '/imports/startup/server/logger';
export default function startPoll(pollType, pollId, secretPoll, question, answers) {
const REDIS_CONFIG = Meteor.settings.private.redis;
const CHANNEL = REDIS_CONFIG.channels.toAkkaApps;
let EVENT_NAME = 'StartPollReqMsg';
try {
const { meetingId, requesterUserId } = extractCredentials(this.userId);
check(meetingId, String);
check(requesterUserId, String);
check(pollId, String);
check(pollType, String);
check(secretPoll, Boolean);
const payload = {
requesterId: requesterUserId,
pollId: `${pollId}/${new Date().getTime()}`,
pollType,
secretPoll,
question,
};
if (pollType === 'custom') {
EVENT_NAME = 'StartCustomPollReqMsg';
check(answers, Array);
payload.answers = answers;
}
RedisPubSub.publishUserMessage(CHANNEL, EVENT_NAME, meetingId, requesterUserId, payload);
} catch (err) {
Logger.error(`Exception while invoking method startPoll ${err.stack}`);
}
}