Skip to content

Commit

Permalink
Regression: Get room's members list not working on MongoDB 3.2 (#13051)
Browse files Browse the repository at this point in the history
* Revert status filter for members list

* Get MongoDB version on statistics
  • Loading branch information
sampaiodiego authored and rodrigok committed Dec 28, 2018
1 parent f5ab945 commit d828b1e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
11 changes: 10 additions & 1 deletion packages/rocketchat-statistics/server/functions/get.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
10 changes: 8 additions & 2 deletions server/methods/getUsersOfRoom.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
};
},
Expand Down

0 comments on commit d828b1e

Please sign in to comment.