feat(bot): bypass max participants limit for bot users

Adjust the maximum participants logic to exempt bot users from being
counted towards the participant limit.
This commit is contained in:
Arthurk12 2024-10-16 13:45:59 -03:00
parent 86ea21e52b
commit 8697de71e8
4 changed files with 6 additions and 4 deletions

View File

@ -83,7 +83,7 @@ trait UserJoinMeetingReqMsgHdlr extends HandlerHelpers {
if (maxParticipants > 0 && //0 = no limit
RegisteredUsers.numUniqueJoinedUsers(liveMeeting.registeredUsers) >= maxParticipants &&
!userHasJoinedAlready) {
!userHasJoinedAlready && !regUser.bot) {
Left(("The maximum number of participants allowed for this meeting has been reached.", EjectReasonCode.MAX_PARTICIPANTS))
} else {
Right(())

View File

@ -67,7 +67,7 @@ object Users2x {
}
def numUsers(users: Users2x): Int = {
users.toVector.filter(u => !u.bot).length
users.toVector.length
}
def numActiveModerators(users: Users2x): Int = {

View File

@ -1076,7 +1076,7 @@ public class MeetingService implements MessageListener {
message.name, message.role, message.locked, message.avatarURL, message.webcamBackgroundURL, message.bot,
message.guest, message.guestStatus, message.clientType);
if(m.getMaxUsers() > 0 && m.countUniqueExtIds() >= m.getMaxUsers()) {
if(m.getMaxUsers() > 0 && m.countUniqueExtIds() >= m.getMaxUsers() && !user.isBot()) {
m.removeEnteredUser(user.getInternalUserId());
return;
}

View File

@ -1864,6 +1864,8 @@ class ApiController {
Boolean reenter = meeting.getEnteredUserById(us.internalUserId) != null;
// User are able to rejoin if he already joined previously with the same extId
Boolean userExtIdAlreadyJoined = meeting.getUsersWithExtId(us.externUserID).size() > 0
// Bot users should not be affected by max partiicpants limitation
Boolean isBot = us.bot
// Users that already joined the meeting
// It will count only unique users in order to avoid the same user from filling all slots
int joinedUniqueUsers = meeting.countUniqueExtIds()
@ -1873,7 +1875,7 @@ class ApiController {
log.info("Entered users - ${enteredUsers}. Joined users - ${joinedUniqueUsers}")
Boolean reachedMax = joinedUniqueUsers >= maxParticipants;
if (enabled && !rejoin && !reenter && !userExtIdAlreadyJoined && reachedMax) {
if (enabled && !rejoin && !reenter && !userExtIdAlreadyJoined && reachedMax && !isBot) {
return true;
}