2016-10-21 21:21:09 +08:00
|
|
|
import { Meteor } from 'meteor/meteor';
|
|
|
|
import { check } from 'meteor/check';
|
2017-10-12 08:33:57 +08:00
|
|
|
import Logger from '/imports/startup/server/logger';
|
2017-10-12 10:00:28 +08:00
|
|
|
import Polls from '/imports/api/polls';
|
2016-10-21 21:21:09 +08:00
|
|
|
|
2018-10-16 03:05:50 +08:00
|
|
|
Meteor.publish('current-poll', (meetingId) => {
|
2018-10-10 23:49:58 +08:00
|
|
|
check(meetingId, String);
|
|
|
|
|
|
|
|
const selector = {
|
|
|
|
meetingId,
|
|
|
|
};
|
|
|
|
|
2019-03-09 00:00:16 +08:00
|
|
|
Logger.debug(`Publishing poll for meeting=${meetingId}`);
|
2018-10-10 23:49:58 +08:00
|
|
|
|
|
|
|
return Polls.find(selector);
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2017-06-01 01:54:43 +08:00
|
|
|
function polls(credentials) {
|
2016-10-21 21:21:09 +08:00
|
|
|
const { meetingId, requesterUserId, requesterToken } = credentials;
|
|
|
|
|
|
|
|
check(meetingId, String);
|
|
|
|
check(requesterUserId, String);
|
|
|
|
check(requesterToken, String);
|
|
|
|
|
2019-03-09 00:00:16 +08:00
|
|
|
Logger.debug(`Publishing polls =${meetingId} ${requesterUserId} ${requesterToken}`);
|
2017-10-12 08:33:57 +08:00
|
|
|
|
2016-10-22 02:56:42 +08:00
|
|
|
const selector = {
|
2017-06-03 03:25:02 +08:00
|
|
|
meetingId,
|
2016-10-22 02:56:42 +08:00
|
|
|
users: requesterUserId,
|
|
|
|
};
|
|
|
|
|
2017-06-06 03:12:06 +08:00
|
|
|
return Polls.find(selector);
|
|
|
|
}
|
|
|
|
|
|
|
|
function publish(...args) {
|
|
|
|
const boundPolls = polls.bind(this);
|
2018-11-06 03:30:37 +08:00
|
|
|
return boundPolls(...args);
|
2017-06-06 03:12:06 +08:00
|
|
|
}
|
2016-10-22 02:56:42 +08:00
|
|
|
|
2017-10-13 03:07:02 +08:00
|
|
|
Meteor.publish('polls', publish);
|