// otherwise we should send messages
Occupant targetOccupant = room.findOccupantByJID(target);
// notify remaining users that user got affiliation updated
PresenceStanzaType presenceType = null;
Status status = null;
Role newRole;
Entity from;
if(targetOccupant != null) {
newRole = targetOccupant.getRole();
from = roomAndNick(room, targetOccupant);
} else {
newRole = Role.None;
from = room.getJID();
}
// only owners can revoke ownership and admin
if((currentAffiliation == Affiliation.Owner || currentAffiliation == Affiliation.Admin) && moderator.getAffiliation() != Affiliation.Owner) {
return MUCHandlerHelper.createErrorReply(stanza, StanzaErrorType.CANCEL,
StanzaErrorCondition.NOT_ALLOWED);
}
// if the occupant is getting revoke as a member, and this is a members-only room, he also needs to leave the room
if((newAffiliation == Affiliation.None && room.isRoomType(RoomType.MembersOnly)) || newAffiliation == Affiliation.Outcast) {
if(newAffiliation == Affiliation.Outcast && targetOccupant.getAffiliation().compareTo(moderator.getAffiliation()) < 0) {
return MUCHandlerHelper.createErrorReply(stanza, StanzaErrorType.CANCEL,
StanzaErrorCondition.NOT_ALLOWED);
}
if(targetOccupant != null) {
room.removeOccupant(target);
}
presenceType = PresenceStanzaType.UNAVAILABLE;
if(newAffiliation == Affiliation.Outcast) {
status = new Status(StatusCode.BEEN_BANNED);
} else {
status = new Status(StatusCode.REMOVED_BY_AFFILIATION);
}
newRole = Role.None;
MucUserItem presenceItem = new MucUserItem(newAffiliation, newRole);