2016-11-17 17:38:38 +09:00
|
|
|
// import Posts from "meteor/nova:posts";
|
|
|
|
// import Users from 'meteor/nova:users';
|
2016-06-23 11:40:35 +09:00
|
|
|
|
2016-11-17 17:38:38 +09:00
|
|
|
// Comments._ensureIndex({postId: 1});
|
|
|
|
// Comments._ensureIndex({parentCommentId: 1});
|
2015-05-08 09:33:27 +09:00
|
|
|
|
2016-11-17 17:38:38 +09:00
|
|
|
// /**
|
|
|
|
// * @summary Publish a list of comments, along with the posts and users corresponding to these comments
|
|
|
|
// * @param {Object} terms
|
|
|
|
// */
|
|
|
|
// Meteor.publish('comments.list', function (terms) {
|
2016-01-02 18:40:49 +01:00
|
|
|
|
2016-11-17 17:38:38 +09:00
|
|
|
// const currentUser = this.userId && Users.findOne(this.userId);
|
2016-02-17 12:54:18 +09:00
|
|
|
|
2016-11-17 17:38:38 +09:00
|
|
|
// terms.currentUserId = this.userId; // add currentUserId to terms
|
|
|
|
// ({selector, options} = Comments.parameters.get(terms));
|
2016-02-17 12:54:18 +09:00
|
|
|
|
2016-11-17 17:38:38 +09:00
|
|
|
// // commenting this because of FR-SSR issue
|
|
|
|
// // Counts.publish(this, 'comments.list', Comments.find(selector, options));
|
2016-02-17 12:54:18 +09:00
|
|
|
|
2016-11-17 17:38:38 +09:00
|
|
|
// options.fields = Comments.publishedFields.list;
|
2016-02-17 12:54:18 +09:00
|
|
|
|
2016-11-17 17:38:38 +09:00
|
|
|
// const comments = Comments.find(selector, options);
|
|
|
|
// const posts = Posts.find({_id: {$in: _.pluck(comments.fetch(), 'postId')}}, {fields: Posts.publishedFields.list});
|
|
|
|
// const users = Users.find({_id: {$in: _.pluck(comments.fetch(), 'userId')}}, {fields: Users.publishedFields.list});
|
2016-02-17 12:54:18 +09:00
|
|
|
|
2016-11-17 17:38:38 +09:00
|
|
|
// return Users.canDo(currentUser, "comments.view.all") ? [comments, posts, users] : [];
|
2016-02-17 12:54:18 +09:00
|
|
|
|
2016-11-17 17:38:38 +09:00
|
|
|
// });
|
2015-05-08 09:33:27 +09:00
|
|
|
|
2015-04-22 07:50:26 +09:00
|
|
|
|
2016-06-23 12:17:39 +09:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-02-17 12:54:18 +09:00
|
|
|
// /**
|
|
|
|
// * Publish a single comment, along with all relevant users
|
|
|
|
// * @param {Object} terms
|
|
|
|
// */
|
|
|
|
// Meteor.publish('comments.single', function(terms) {
|
2015-07-10 11:05:13 +09:00
|
|
|
|
2016-02-17 12:54:18 +09:00
|
|
|
// check(terms, {_id: String});
|
2015-07-10 11:05:13 +09:00
|
|
|
|
2016-02-17 17:46:34 +09:00
|
|
|
//
|
2016-01-02 18:40:49 +01:00
|
|
|
|
2016-02-17 12:54:18 +09:00
|
|
|
// let commentIds = [terms._id];
|
|
|
|
// const childCommentIds = _.pluck(Comments.find({parentCommentId: terms._id}, {fields: {_id: 1}}).fetch(), '_id');
|
|
|
|
// commentIds = commentIds.concat(childCommentIds);
|
|
|
|
|
2016-07-20 10:25:05 +09:00
|
|
|
// return Users.canView(currentUser) ? Comments.find({_id: {$in: commentIds}}, {sort: {score: -1, postedAt: -1}}) : [];
|
2016-02-17 12:54:18 +09:00
|
|
|
|
2016-02-16 16:12:13 +09:00
|
|
|
// });
|
2015-04-22 07:50:26 +09:00
|
|
|
|
2016-02-17 12:54:18 +09:00
|
|
|
|
|
|
|
|
|
|
|
|
2016-02-16 16:12:13 +09:00
|
|
|
// // Publish the post related to the current comment
|
2015-04-22 07:50:26 +09:00
|
|
|
|
2016-02-16 16:12:13 +09:00
|
|
|
// Meteor.publish('commentPost', function(commentId) {
|
2015-07-10 11:05:13 +09:00
|
|
|
|
2016-02-16 16:12:13 +09:00
|
|
|
// check(commentId, String);
|
2015-07-10 11:05:13 +09:00
|
|
|
|
2016-02-17 17:46:34 +09:00
|
|
|
//
|
2016-01-02 18:40:49 +01:00
|
|
|
|
2016-07-20 10:25:05 +09:00
|
|
|
// if(Users.canViewById(this.userId)){
|
2016-02-16 16:12:13 +09:00
|
|
|
// var comment = Comments.findOne(commentId);
|
|
|
|
// return Posts.find({_id: comment && comment.postId});
|
|
|
|
// }
|
|
|
|
// return [];
|
|
|
|
// });
|
2015-04-22 07:50:26 +09:00
|
|
|
|
2016-02-16 16:12:13 +09:00
|
|
|
// // Publish author of the current comment, and author of the post related to the current comment
|
2015-04-22 07:50:26 +09:00
|
|
|
|
2016-02-16 16:12:13 +09:00
|
|
|
// Meteor.publish('commentUsers', function(commentId) {
|
2015-04-22 07:50:26 +09:00
|
|
|
|
2016-02-16 16:12:13 +09:00
|
|
|
// check(commentId, String);
|
2016-01-02 18:40:49 +01:00
|
|
|
|
2016-02-17 17:46:34 +09:00
|
|
|
//
|
2016-01-02 18:40:49 +01:00
|
|
|
|
2016-02-16 16:12:13 +09:00
|
|
|
// var userIds = [];
|
2015-04-22 07:50:26 +09:00
|
|
|
|
2016-07-20 10:25:05 +09:00
|
|
|
// if(Users.canViewById(this.userId)){
|
2015-04-22 07:50:26 +09:00
|
|
|
|
2016-02-16 16:12:13 +09:00
|
|
|
// var comment = Comments.findOne(commentId);
|
2015-05-21 15:51:19 +09:00
|
|
|
|
2016-02-16 16:12:13 +09:00
|
|
|
// if (!!comment) {
|
|
|
|
// userIds.push(comment.userId);
|
2015-04-22 07:50:26 +09:00
|
|
|
|
2016-02-16 16:12:13 +09:00
|
|
|
// var post = Posts.findOne(comment.postId);
|
|
|
|
// if (!!post) {
|
|
|
|
// userIds.push(post.userId);
|
|
|
|
// }
|
2015-04-22 07:50:26 +09:00
|
|
|
|
2016-10-05 08:37:48 +02:00
|
|
|
// return Users.find({_id: {$in: userIds}}, {fields: Users.pubsub.publicProperties});
|
2015-05-21 15:51:19 +09:00
|
|
|
|
2016-02-16 16:12:13 +09:00
|
|
|
// }
|
2015-04-22 07:50:26 +09:00
|
|
|
|
2016-02-16 16:12:13 +09:00
|
|
|
// }
|
2015-04-22 07:50:26 +09:00
|
|
|
|
2016-02-16 16:12:13 +09:00
|
|
|
// return [];
|
2015-04-22 07:50:26 +09:00
|
|
|
|
2016-02-16 16:12:13 +09:00
|
|
|
// });
|