bigbluebutton-Github/bigbluebutton-html5/imports/ui/components/polling/service.js
Gabriel Carvalho de Campes a7335633d4 Refactor Poll API
2016-10-21 11:21:09 -02:00

26 lines
554 B
JavaScript
Executable File

import { callServer } from '/imports/ui/services/api';
import Polls from '/imports/api/polls';
let mapPolls = function () {
let poll = Polls.findOne({});
if (!poll) {
return { pollExists: false };
}
const amIRequester = poll.requester != 'userId';
return {
poll: {
answers: poll.poll.answers,
pollId: poll.poll.id,
},
pollExists: true,
amIRequester: amIRequester,
handleVote: function (pollId, answerId) {
callServer('publishVote', pollId, answerId.id);
},
};
};
export default { mapPolls };