mirror of
https://github.com/vale981/Vulcan
synced 2025-03-06 10:01:40 -05:00
add userId to terms when passed from publication or template controller
This commit is contained in:
parent
993a5f65a8
commit
9a927d428a
4 changed files with 21 additions and 0 deletions
|
@ -41,6 +41,9 @@ Template.posts_list_controller.onCreated(function () {
|
|||
// get terms from data context
|
||||
var terms = Template.currentData().terms; // ⚡ reactive ⚡
|
||||
|
||||
// add current userId to terms
|
||||
terms.userId = Meteor.userId();
|
||||
|
||||
// get limit from local template variable
|
||||
var postsLimit = instance.postsLimit.get(); // ⚡ reactive ⚡
|
||||
|
||||
|
|
|
@ -3,6 +3,9 @@ Posts._ensureIndex({"status": 1, "postedAt": 1});
|
|||
// Publish a list of posts
|
||||
|
||||
Meteor.publish('postsList', function(terms) {
|
||||
|
||||
terms.userId = this.userId; // add userId to terms
|
||||
|
||||
if(Users.can.viewById(this.userId)){
|
||||
var parameters = Posts.parameters.get(terms),
|
||||
posts = Posts.find(parameters.find, parameters.options);
|
||||
|
@ -16,6 +19,9 @@ Meteor.publish('postsList', function(terms) {
|
|||
// plus the commenters for each post
|
||||
|
||||
Meteor.publish('postsListUsers', function(terms) {
|
||||
|
||||
terms.userId = this.userId; // add userId to terms
|
||||
|
||||
if(Users.can.viewById(this.userId)){
|
||||
var parameters = Posts.parameters.get(terms),
|
||||
posts = Posts.find(parameters.find, parameters.options),
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
Meteor.publish('userSubscribedPosts', function(terms) {
|
||||
|
||||
terms.userId = this.userId; // add userId to terms
|
||||
|
||||
var parameters = Posts.parameters.get(terms);
|
||||
var posts = Posts.find(parameters.find, parameters.options);
|
||||
return posts;
|
||||
|
|
|
@ -11,18 +11,27 @@ Meteor.publish('singleUser', function(idOrSlug) {
|
|||
});
|
||||
|
||||
Meteor.publish('userPosts', function(terms) {
|
||||
|
||||
terms.userId = this.userId; // add userId to terms
|
||||
|
||||
var parameters = Posts.parameters.get(terms);
|
||||
var posts = Posts.find(parameters.find, parameters.options);
|
||||
return posts;
|
||||
});
|
||||
|
||||
Meteor.publish('userUpvotedPosts', function(terms) {
|
||||
|
||||
terms.userId = this.userId; // add userId to terms
|
||||
|
||||
var parameters = Posts.parameters.get(terms);
|
||||
var posts = Posts.find(parameters.find, parameters.options);
|
||||
return posts;
|
||||
});
|
||||
|
||||
Meteor.publish('userDownvotedPosts', function(terms) {
|
||||
|
||||
terms.userId = this.userId; // add userId to terms
|
||||
|
||||
var parameters = Posts.parameters.get(terms);
|
||||
var posts = Posts.find(parameters.find, parameters.options);
|
||||
return posts;
|
||||
|
|
Loading…
Add table
Reference in a new issue