mirror of
https://github.com/vale981/Vulcan
synced 2025-03-08 19:11:38 -05:00

Switched everything over to use can.* functions from telescope-lib instead of using can* functions from lib/permissions.js, deleted lib/permissions.js, added some tests for permissions, and some other random cleanup like deleting unused code. Conflicts: client/views/comments/comment_form.js
38 lines
No EOL
949 B
JavaScript
38 lines
No EOL
949 B
JavaScript
// Publish a single post
|
|
|
|
Meteor.publish('singlePost', function(id) {
|
|
if (can.viewById(this.userId)){
|
|
return Posts.find(id);
|
|
}
|
|
return [];
|
|
});
|
|
|
|
// Publish authors of the current post and its comments
|
|
|
|
Meteor.publish('postUsers', function(postId) {
|
|
if (can.viewById(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 (can.viewById(this.userId)){
|
|
return Comments.find({postId: postId});
|
|
}
|
|
return [];
|
|
}); |