powered by Jive Software

Joining a room that has hit max occupancy when you're an owner/admin

XEP-0045 states:

“If the room has reached its maximum number of occupants and a room admin or owner attempts to join, the room SHOULD allow the admin or owner to join, up to some reasonable number of additional occupants, which number MAY be configurable.”

I’m putting a patch together against 3.7 to implement this, would someone mind raising a JIRA ticket for it I can attach the patch to?

Thanks

OF-411 Thanks for the patch Attach the patch here and i will attach it to the ticket.

Index: src/java/org/jivesoftware/openfire/muc/spi/LocalMUCRoom.java

===================================================================

— src/java/org/jivesoftware/openfire/muc/spi/LocalMUCRoom.java (revision 12000)

+++ src/java/org/jivesoftware/openfire/muc/spi/LocalMUCRoom.java (working copy)

@@ -497,6 +497,8 @@

return MUCRole.Affiliation.none;

}

public LocalMUCRole joinRoom(String nickname, String password, HistoryRequest historyRequest,

LocalMUCUser user, Presence presence) throws UnauthorizedException,

UserAlreadyExistsException, RoomLockedException, ForbiddenException,

@@ -512,7 +514,7 @@

lock.writeLock().lock();

try {

// If the room has a limit of max user then check if the limit has been reached

  •        if (isDestroyed || (getMaxUsers() > 0 && getOccupantsCount() >= getMaxUsers())) {
    
  •        if (!canJoinRoom(user)) {
    

throw new ServiceUnavailableException();

}

boolean isOwner = owners.contains(user.getAddress().toBareJID());

@@ -688,6 +690,16 @@

MUCEventDispatcher.occupantJoined(getRole().getRoleAddress(), user.getAddress(), joinRole.getNickname());

return joinRole;

}

  • private boolean canJoinRoom(LocalMUCUser user){

  •     boolean isOwner = owners.contains(user.getAddress().toBareJID());
    
  •     boolean isAdmin = admins.contains(user.getAddress().toBareJID());
    
  •     return (!isDestroyed && (!hasOccupancyLimit() || isAdmin || isOwner || (getOccupantsCount() < getMaxUsers())));
    
  • }

  • private boolean hasOccupancyLimit(){

  •     return getMaxUsers() != 0;
    
  • }

/**

  • Sends presence of existing occupants to new occupant.

attached to the ticket