2013-10-21 18:56:22 +08:00
|
|
|
var userFieldsPrivacy = { // false means private
|
|
|
|
secret_id: false,
|
|
|
|
isAdmin: false,
|
|
|
|
emails: false,
|
|
|
|
notifications: false,
|
|
|
|
'profile.email': false,
|
|
|
|
'services.twitter.accessToken': false,
|
|
|
|
'services.twitter.accessTokenSecret': false,
|
|
|
|
'services.twitter.id': false,
|
|
|
|
'services.password': false,
|
|
|
|
'services.resume': false
|
|
|
|
};
|
|
|
|
|
2013-07-04 12:51:26 +09:00
|
|
|
// Users
|
|
|
|
|
2012-10-18 14:24:36 +09:00
|
|
|
Meteor.publish('currentUser', function() {
|
2012-10-19 15:53:26 +11:00
|
|
|
return Meteor.users.find(this.userId);
|
2012-10-18 14:24:36 +09:00
|
|
|
});
|
2013-10-09 22:16:47 +09:00
|
|
|
|
2013-10-21 18:56:22 +08:00
|
|
|
Meteor.publish('singleUser', function(userId) {
|
|
|
|
if(isAdminById(this.userId)){
|
|
|
|
return Meteor.users.find(userId);
|
|
|
|
}else{
|
|
|
|
return Meteor.users.find(userId, {fields: userFieldsPrivacy});
|
|
|
|
}
|
2013-10-09 22:16:47 +09:00
|
|
|
});
|
2013-10-21 18:56:22 +08:00
|
|
|
|
2012-10-18 14:24:36 +09:00
|
|
|
Meteor.publish('allUsers', function() {
|
2013-10-09 22:16:47 +09:00
|
|
|
if (isAdminById(this.userId)) {
|
2012-10-18 14:24:36 +09:00
|
|
|
// if user is admin, publish all fields
|
2012-09-18 16:23:33 +09:00
|
|
|
return Meteor.users.find();
|
|
|
|
}else{
|
2012-10-18 14:24:36 +09:00
|
|
|
// else, filter out sensitive info
|
2013-10-21 18:56:22 +08:00
|
|
|
return Meteor.users.find({}, {fields: userFieldsPrivacy});
|
2012-09-18 16:23:33 +09:00
|
|
|
}
|
2012-09-06 15:28:58 +09:00
|
|
|
});
|
2012-09-19 09:03:25 +09:00
|
|
|
|
2012-08-22 23:24:33 -04:00
|
|
|
// Posts
|
|
|
|
|
2012-12-13 18:12:08 +11:00
|
|
|
// a single post, identified by id
|
2013-04-06 14:27:01 +09:00
|
|
|
Meteor.publish('singlePost', function(id) {
|
2012-12-13 18:12:08 +11:00
|
|
|
return Posts.find(id);
|
|
|
|
});
|
2012-12-06 23:46:20 +11:00
|
|
|
|
|
|
|
Meteor.publish('paginatedPosts', function(find, options, limit) {
|
|
|
|
options = options || {};
|
|
|
|
options.limit = limit;
|
|
|
|
return Posts.find(find || {}, options);
|
|
|
|
});
|
|
|
|
|
2013-04-14 12:42:32 +10:00
|
|
|
Meteor.publish('postDigest', function(date) {
|
|
|
|
var mDate = moment(date);
|
|
|
|
return findDigestPosts(mDate);
|
|
|
|
});
|
|
|
|
|
2013-07-04 12:51:26 +09:00
|
|
|
// Other Publications
|
2012-08-22 23:24:33 -04:00
|
|
|
|
2012-10-10 11:03:09 +09:00
|
|
|
Meteor.publish('comments', function(query) {
|
|
|
|
return Comments.find(query);
|
2012-08-22 23:24:33 -04:00
|
|
|
});
|
|
|
|
|
2012-09-06 19:42:11 +09:00
|
|
|
Meteor.publish('settings', function() {
|
|
|
|
return Settings.find();
|
2012-09-06 11:34:05 +09:00
|
|
|
});
|
|
|
|
|
2012-10-05 10:23:38 +09:00
|
|
|
Meteor.publish('notifications', function() {
|
2012-10-10 07:28:44 +09:00
|
|
|
// only publish notifications belonging to the current user
|
2012-11-19 15:41:44 +09:00
|
|
|
return Notifications.find({userId:this.userId});
|
2012-10-05 10:23:38 +09:00
|
|
|
});
|
|
|
|
|
2012-10-10 07:28:44 +09:00
|
|
|
Meteor.publish('categories', function() {
|
|
|
|
return Categories.find();
|
2012-09-06 11:34:05 +09:00
|
|
|
});
|