Commit 5c17fedb authored by Daryl Herzmann's avatar Daryl Herzmann Committed by akrherz

OF-411 allow MUC admin/owners to join a room at occupancy limit as per XEP-0045

git-svn-id: http://svn.igniterealtime.org/svn/repos/openfire/trunk@13941 b35dd754-fafc-0310-a699-88a17e54d16e
parent df80165a
......@@ -518,7 +518,7 @@ public class LocalMUCRoom implements MUCRoom {
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();
}
final JID bareJID = user.getAddress().asBareJID();
......@@ -696,6 +696,27 @@ public class LocalMUCRoom implements MUCRoom {
return joinRole;
}
/**
* Can a user join this room
*
* @param user the user attempting to join this room
* @return boolean
*/
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())));
}
/**
* Does this room have an occupancy limit?
*
* @return boolean
*/
private boolean hasOccupancyLimit(){
return getMaxUsers() != 0;
}
/**
* Sends presence of existing occupants to new occupant.
*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment