fix: Space out approval of guests to better handle larger groups (#21416)

Space out the group handling of guest accept all.
Handle the groups in batches of up to three.
Dispatch a new batch approval every 500ms (configurable)
This commit is contained in:
Anton Georgiev 2024-10-10 20:05:13 -04:00 committed by GitHub
parent 3fcfe5acfc
commit 279ce6b4d6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 21 additions and 1 deletions

View File

@ -3,7 +3,26 @@ import Auth from '/imports/ui/services/auth';
import GuestUsers from '/imports/api/guest-users';
import { makeCall } from '/imports/ui/services/api';
const guestUsersCall = (guestsArray, status) => makeCall('allowPendingUsers', guestsArray, status);
const sizeOfBatches = 3; // commonly deployments have 3-4 or more instances of bbb-html5-frontend
const delayForApprovalOfGuests = Meteor.settings.public.app.delayForApprovalOfGuests || 500;
const breakIntoSmallerGroups = (array) => {
return array
.map((_, index) => {
return index % sizeOfBatches === 0 ? array.slice(index, index + sizeOfBatches) : null;
})
.filter(group => group) // remove null values
.map(group => group.filter(item => item !== undefined)); // remove undefined items
};
async function guestUsersCall(guestsArray, status) {
// Processing large arrays (20+ guests) puts a lot of stress on frontends
// Here we split the approved guests into batches and space out the batch processing
for (const batch of breakIntoSmallerGroups(guestsArray)) {
makeCall('allowPendingUsers', batch, status);
await new Promise(resolve => setTimeout(resolve, delayForApprovalOfGuests));
};
}
const changeGuestPolicy = (policyRule) => makeCall('changeGuestPolicy', policyRule);

View File

@ -66,6 +66,7 @@ public:
dynamicGuestPolicy: true
enableGuestLobbyMessage: true
guestPolicyExtraAllowOptions: false
delayForApprovalOfGuests: 500
alwaysShowWaitingRoomUI: true
enableLimitOfViewersInWebcam: false
enableMultipleCameras: true