bugfix: only care active members, also optimize some code

This commit is contained in:
floatinghotpot 2015-12-08 16:03:31 +08:00
parent b719968df5
commit 672c21bfe0
9 changed files with 62 additions and 78 deletions

View file

@ -1,8 +1,7 @@
allowIsBoardAdmin = function(userId, board) {
const admins = _.pluck(_.where(board.members, {isAdmin: true}), 'userId');
return _.contains(admins, userId);
return board && board.hasAdmin(userId);
};
allowIsBoardMember = function(userId, board) {
return _.contains(_.pluck(board.members, 'userId'), userId);
return board && board.hasMember(userId);
};

View file

@ -16,7 +16,7 @@ Meteor.publish('boards', function() {
return Boards.find({
archived: false,
$or: [
{ 'members.userId': this.userId },
{ members: { $elemMatch: { userId: this.userId, isActive: true }}},
{ _id: { $in: starredBoards } },
],
}, {
@ -66,7 +66,7 @@ Meteor.publishComposite('board', function(boardId) {
// it.
$or: [
{ permission: 'public' },
{ 'members.userId': this.userId },
{ members: { $elemMatch: { userId: this.userId, isActive: true }}},
],
}, { limit: 1 });
},