From 7b5d08afd143baa835ecc40eab115d353e5d87dd Mon Sep 17 00:00:00 2001 From: David Renshaw Date: Mon, 21 Nov 2016 22:49:53 -0500 Subject: fix bug where old users could see broken presence indicators on new users --- server/publications/boards.js | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/server/publications/boards.js b/server/publications/boards.js index cd3ef238..fd352552 100644 --- a/server/publications/boards.js +++ b/server/publications/boards.js @@ -99,20 +99,21 @@ 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. + 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 })); + }); + } }); return this.ready(); -- cgit v1.2.3-1-g7c22 From be47357cd4c88072c5ab5ebdfb790d06d92691ae Mon Sep 17 00:00:00 2001 From: David Renshaw Date: Tue, 22 Nov 2016 10:34:31 -0500 Subject: don't chain the presences cursor on the users cursor --- server/publications/boards.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/server/publications/boards.js b/server/publications/boards.js index fd352552..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, @@ -103,16 +104,20 @@ Meteor.publishRelations('board', function(boardId) { // 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: _.pluck(board.members, 'userId') }, + _id: { $in: _.without(memberIds, thisUserId)}, }, { fields: { 'username': 1, 'profile.fullname': 1, 'profile.avatarUrl': 1, - }}), function(userId) { - // Presence indicators - this.cursor(presences.find({ userId })); - }); + }})); + + this.cursor(presences.find({ userId: { $in: memberIds } })); } }); -- cgit v1.2.3-1-g7c22