Skip to content

Commit

Permalink
[FIX] Active users count on @all and @here (#25957)
Browse files Browse the repository at this point in the history
Co-authored-by: Matheus Barbosa Silva <[email protected]>
  • Loading branch information
2 people authored and csuarez committed Aug 26, 2022
1 parent e71950d commit abd0f51
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ export async function sendMessageNotifications(message, room, usersInThread = []

// Don't fetch all users if room exceeds max members
const maxMembersForNotification = settings.get('Notifications_Max_Room_Members');
const roomMembersCount = Subscriptions.findByRoomId(room._id).count();
const roomMembersCount = await Users.countRoomMembers(room._id);
const disableAllMessageNotifications = roomMembersCount > maxMembersForNotification && maxMembersForNotification !== 0;

const query = {
Expand Down
4 changes: 4 additions & 0 deletions apps/meteor/app/models/server/models/Users.js
Original file line number Diff line number Diff line change
Expand Up @@ -1655,6 +1655,10 @@ Find users to send a message by email if:
},
});
}

countRoomMembers(roomId) {
return this.find({ __rooms: roomId, active: true }).count();
}
}

export default new Users(Meteor.users, true);

0 comments on commit abd0f51

Please sign in to comment.