From d828b1efa22d80e57fcc5e86556d790d149f3c3c Mon Sep 17 00:00:00 2001 From: Diego Sampaio Date: Fri, 28 Dec 2018 18:33:54 -0200 Subject: [PATCH] Regression: Get room's members list not working on MongoDB 3.2 (#13051) * Revert status filter for members list * Get MongoDB version on statistics --- .../rocketchat-statistics/server/functions/get.js | 11 ++++++++++- server/methods/getUsersOfRoom.js | 10 ++++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/packages/rocketchat-statistics/server/functions/get.js b/packages/rocketchat-statistics/server/functions/get.js index df0be96e356a..cc6a70c2f146 100644 --- a/packages/rocketchat-statistics/server/functions/get.js +++ b/packages/rocketchat-statistics/server/functions/get.js @@ -105,9 +105,18 @@ RocketChat.statistics.get = function _getStatistics() { statistics.migration = RocketChat.Migrations._getControl(); statistics.instanceCount = InstanceStatus.getCollection().find({ _updatedAt: { $gt: new Date(Date.now() - process.uptime() * 1000 - 2000) } }).count(); - if (MongoInternals.defaultRemoteCollectionDriver().mongo._oplogHandle && MongoInternals.defaultRemoteCollectionDriver().mongo._oplogHandle.onOplogEntry && RocketChat.settings.get('Force_Disable_OpLog_For_Cache') !== true) { + const { mongo } = MongoInternals.defaultRemoteCollectionDriver(); + + if (mongo._oplogHandle && mongo._oplogHandle.onOplogEntry && RocketChat.settings.get('Force_Disable_OpLog_For_Cache') !== true) { statistics.oplogEnabled = true; } + try { + const { version } = Promise.await(mongo.db.command({ buildInfo: 1 })); + statistics.mongoVersion = version; + } catch (e) { + console.error('Error getting MongoDB version'); + } + return statistics; }; diff --git a/server/methods/getUsersOfRoom.js b/server/methods/getUsersOfRoom.js index a939fa914570..d6bced8f9bc2 100644 --- a/server/methods/getUsersOfRoom.js +++ b/server/methods/getUsersOfRoom.js @@ -39,8 +39,14 @@ Meteor.methods({ 'u.status': 1, }, }, - ...(showAll ? [] : [{ $match: { 'u.status': 'online' } }]), - { $replaceRoot: { newRoot: { $arrayElemAt: ['$u', 0] } } }, + ...(showAll ? [] : [{ $match: { 'u.status': { $in: ['online', 'away', 'busy'] } } }]), + { + $project: { + _id: { $arrayElemAt: ['$u._id', 0] }, + name: { $arrayElemAt: ['$u.name', 0] }, + username: { $arrayElemAt: ['$u.username', 0] }, + }, + }, ]).toArray(), }; },