Skip to content

Commit

Permalink
Merge pull request #8520 from RocketChat/hotifx/cpu-load
Browse files Browse the repository at this point in the history
Fix high CPU load when sending messages on large rooms (regression)
  • Loading branch information
rodrigok authored Oct 18, 2017
2 parents 5ee30aa + ff8074e commit fc23133
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion server/publications/room.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)));
}
}
});

Expand Down

0 comments on commit fc23133

Please sign in to comment.