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';
|
2017-06-01 01:54:43 +08:00
|
|
|
import mapToAcl from '/imports/startup/mapToAcl';
|
2016-10-21 21:21:09 +08:00
|
|
|
|
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);
|
|
|
|
|
2017-10-13 03:07:02 +08:00
|
|
|
Logger.info(`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);
|
|
|
|
return mapToAcl('subscriptions.polls', boundPolls)(args);
|
|
|
|
}
|
2016-10-22 02:56:42 +08:00
|
|
|
|
2017-10-13 03:07:02 +08:00
|
|
|
Meteor.publish('polls', publish);
|
2016-10-22 02:56:42 +08:00
|
|
|
|