From ff8074e441e9a62dcddea645dde94bc6a236a460 Mon Sep 17 00:00:00 2001 From: Rodrigo Nascimento Date: Wed, 18 Oct 2017 00:55:35 -0200 Subject: [PATCH] Fix high CPU load when sending messages on large rooms (regression) --- server/publications/room.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/server/publications/room.js b/server/publications/room.js index c52722cf67d5..047a9318b87a 100644 --- a/server/publications/room.js +++ b/server/publications/room.js @@ -106,7 +106,10 @@ Meteor.methods({ RocketChat.models.Rooms.cache.on('sync', (type, room/*, diff*/) => { const records = RocketChat.models.Subscriptions.findByRoomId(room._id).fetch(); for (const record of records) { - RocketChat.Notifications.notifyUserInThisInstance(record.u._id, 'rooms-changed', type, roomMap({_room: room}, getFieldsForUserId(record.u._id))); + const user = RocketChat.models.Users.findOneById(record.u._id); + if (user && (user.statusConnection === 'online' || user.statusConnection === 'away')) { + RocketChat.Notifications.notifyUserInThisInstance(record.u._id, 'rooms-changed', type, roomMap({_room: room}, getFieldsForUserId(record.u._id))); + } } });