mirror of
https://github.com/vale981/Vulcan
synced 2025-03-09 20:16:39 -04: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
32 lines
995 B
JavaScript
32 lines
995 B
JavaScript
// Publish a single comment
|
|
|
|
Meteor.publish('singleComment', function(commentId) {
|
|
if(can.viewById(this.userId)){
|
|
// publish both current comment and child comments
|
|
var commentIds = [commentId];
|
|
var childCommentIds = _.pluck(Comments.find({parentCommentId: commentId}, {fields: {_id: 1}}).fetch(), '_id');
|
|
commentIds = commentIds.concat(childCommentIds);
|
|
return Comments.find({_id: {$in: commentIds}});
|
|
}
|
|
return [];
|
|
});
|
|
|
|
// Publish the post related to the current comment
|
|
|
|
Meteor.publish('commentPost', function(commentId) {
|
|
if(can.viewById(this.userId)){
|
|
var comment = Comments.findOne(commentId);
|
|
return Posts.find({_id: comment && comment.postId});
|
|
}
|
|
return [];
|
|
});
|
|
|
|
// Publish author of the current comment
|
|
|
|
Meteor.publish('commentUser', function(commentId) {
|
|
if(can.viewById(this.userId)){
|
|
var comment = Comments.findOne(commentId);
|
|
return Meteor.users.find({_id: comment && comment.userId}, {fields: privacyOptions});
|
|
}
|
|
return [];
|
|
});
|