mirror of
https://github.com/vale981/Vulcan
synced 2025-03-09 12:16:37 -04:00
38 lines
No EOL
942 B
JavaScript
38 lines
No EOL
942 B
JavaScript
// Publish a single post
|
|
|
|
Meteor.publish('singlePost', function(id) {
|
|
if(canViewById(this.userId)){
|
|
return Posts.find(id);
|
|
}
|
|
return [];
|
|
});
|
|
|
|
// Publish authors of the current post and its comments
|
|
|
|
Meteor.publish('postUsers', function(postId) {
|
|
if(canViewById(this.userId)){
|
|
// publish post author and post commenters
|
|
var post = Posts.findOne(postId),
|
|
users = [];
|
|
|
|
if(post) {
|
|
var comments = Comments.find({postId: post._id}).fetch();
|
|
// get IDs from all commenters on the post, plus post author's ID
|
|
users = _.pluck(comments, "userId");
|
|
users.push(post.userId);
|
|
users = _.unique(users);
|
|
}
|
|
|
|
return Meteor.users.find({_id: {$in: users}}, {fields: privacyOptions});
|
|
}
|
|
return [];
|
|
});
|
|
|
|
// Publish comments for a specific post
|
|
|
|
Meteor.publish('postComments', function(postId) {
|
|
if(canViewById(this.userId)){
|
|
return Comments.find({postId: postId});
|
|
}
|
|
return [];
|
|
}); |