diff --git a/bigbluebutton-html5/imports/api/polls/server/methods/publishVote.js b/bigbluebutton-html5/imports/api/polls/server/methods/publishVote.js index 66b6dd938b5870463812b7982bec77cc30332e91..6d5281e43e7b692cb83379b058543638ec9d1ce3 100644 --- a/bigbluebutton-html5/imports/api/polls/server/methods/publishVote.js +++ b/bigbluebutton-html5/imports/api/polls/server/methods/publishVote.js @@ -4,41 +4,34 @@ import Polls from '/imports/api/polls'; import Logger from '/imports/startup/server/logger'; import { extractCredentials } from '/imports/api/common/server/helpers'; -export default function publishVote(id, pollAnswerId) { // TODO discuss location +export default function publishVote(pollId, pollAnswerId) { const REDIS_CONFIG = Meteor.settings.private.redis; const CHANNEL = REDIS_CONFIG.channels.toAkkaApps; const EVENT_NAME = 'RespondToPollReqMsg'; const { meetingId, requesterUserId } = extractCredentials(this.userId); - /* - We keep an array of people who were in the meeting at the time the poll - was started. The poll is published to them only. - Once they vote - their ID is removed and they cannot see the poll anymore - */ - const currentPoll = Polls.findOne({ + + check(pollAnswerId, Number); + check(pollId, String); + + const selector = { users: requesterUserId, meetingId, 'answers.id': pollAnswerId, - id, - }); - - check(pollAnswerId, Number); - check(currentPoll, Object); - check(currentPoll.meetingId, String); + }; const payload = { requesterId: requesterUserId, - pollId: currentPoll.id, + pollId, questionId: 0, answerId: pollAnswerId, }; - const selector = { - users: requesterUserId, - meetingId, - 'answers.id': pollAnswerId, - }; - + /* + We keep an array of people who were in the meeting at the time the poll + was started. The poll is published to them only. + Once they vote - their ID is removed and they cannot see the poll anymore + */ const modifier = { $pull: { users: requesterUserId, @@ -47,11 +40,11 @@ export default function publishVote(id, pollAnswerId) { // TODO discuss location const cb = (err) => { if (err) { - return Logger.error(`Updating Polls collection: ${err}`); + return Logger.error(`Removing responded user from Polls collection: ${err}`); } - return Logger.info(`Updating Polls collection (meetingId: ${meetingId}, ` - + `pollId: ${currentPoll.id}!)`); + return Logger.info(`Removed responded user=${requesterUserId} from poll (meetingId: ${meetingId}, ` + + `pollId: ${pollId}!)`); }; Polls.update(selector, modifier, cb); diff --git a/bigbluebutton-html5/imports/ui/components/polling/component.jsx b/bigbluebutton-html5/imports/ui/components/polling/component.jsx index c0e7219a2e0c5d489de596adc565d91b9a585b99..6d68a4907d69d12e8a3d4c9529e938db781bef03 100644 --- a/bigbluebutton-html5/imports/ui/components/polling/component.jsx +++ b/bigbluebutton-html5/imports/ui/components/polling/component.jsx @@ -42,6 +42,9 @@ class Polling extends Component { handleVote, pollAnswerIds, } = this.props; + + if (!poll) return null; + const { stackOptions, answers } = poll; const pollAnswerStyles = { [styles.pollingAnswers]: true,