diff options
author | Lauri Ojansivu <x@xet7.org> | 2016-11-29 03:23:07 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-11-29 03:23:07 +0200 |
commit | 96e5e8d0585fe781518ea85734e12cfe46e9583f (patch) | |
tree | c6ad3fdc81393220a25b16e1cdf7d4feabbee36a | |
parent | 1ad41072010fb59fdbace80a0aa049634074dac1 (diff) | |
parent | be47357cd4c88072c5ab5ebdfb790d06d92691ae (diff) | |
download | wekan-96e5e8d0585fe781518ea85734e12cfe46e9583f.tar.gz wekan-96e5e8d0585fe781518ea85734e12cfe46e9583f.tar.bz2 wekan-96e5e8d0585fe781518ea85734e12cfe46e9583f.zip |
Merge pull request #25 from dwrensha/board-members-join
fix bug where old users could see broken presence indicators on new users
-rw-r--r-- | server/publications/boards.js | 34 |
1 files changed, 20 insertions, 14 deletions
diff --git a/server/publications/boards.js b/server/publications/boards.js index cd3ef238..89681978 100644 --- a/server/publications/boards.js +++ b/server/publications/boards.js @@ -60,6 +60,7 @@ Meteor.publish('archivedBoards', function() { Meteor.publishRelations('board', function(boardId) { check(boardId, String); + const thisUserId = this.userId; this.cursor(Boards.find({ _id: boardId, @@ -99,20 +100,25 @@ Meteor.publishRelations('board', function(boardId) { this.cursor(Attachments.find({ cardId })); }); - // Board members. This publication also includes former board members that - // aren't members anymore but may have some activities attached to them in - // the history. - // - this.cursor(Users.find({ - _id: { $in: _.pluck(board.members, 'userId') }, - }, { fields: { - 'username': 1, - 'profile.fullname': 1, - 'profile.avatarUrl': 1, - }}), function(userId) { - // Presence indicators - this.cursor(presences.find({ userId })); - }); + if (board.members) { + // Board members. This publication also includes former board members that + // aren't members anymore but may have some activities attached to them in + // the history. + const memberIds = _.pluck(board.members, 'userId'); + + // We omit the current user because the client should already have that data, + // and sending it triggers a subtle bug: + // https://github.com/wefork/wekan/issues/15 + this.cursor(Users.find({ + _id: { $in: _.without(memberIds, thisUserId)}, + }, { fields: { + 'username': 1, + 'profile.fullname': 1, + 'profile.avatarUrl': 1, + }})); + + this.cursor(presences.find({ userId: { $in: memberIds } })); + } }); return this.ready(); |