status = new Status(StatusCode.REMOVED_BY_AFFILIATION);
}
newRole = Role.None;
MucUserItem presenceItem = new MucUserItem(newAffiliation, newRole);
Stanza presenceToFormerMember = MUCStanzaBuilder.createPresenceStanza(from, targetOccupant.getJid(),
presenceType, NamespaceURIs.XEP0045_MUC_USER, presenceItem, status);
relayStanza(targetOccupant.getJid(), presenceToFormerMember, serverRuntimeContext);
} else if(newAffiliation == Affiliation.Owner || newAffiliation == Affiliation.Admin) {
if(moderator.getAffiliation() != Affiliation.Owner) {
return MUCHandlerHelper.createErrorReply(stanza, StanzaErrorType.CANCEL,
StanzaErrorCondition.NOT_ALLOWED);
}
}
room.getAffiliations().add(target, newAffiliation);
if(targetOccupant != null) {
MucUserItem presenceItem = new MucUserItem(newAffiliation, newRole);
for (Occupant occupant : room.getOccupants()) {
Stanza presenceToRemaining = MUCStanzaBuilder.createPresenceStanza(from, occupant.getJid(),
presenceType, NamespaceURIs.XEP0045_MUC_USER, presenceItem, status);
relayStanza(occupant.getJid(), presenceToRemaining, serverRuntimeContext);
}
} else {
room.getAffiliations().add(target, newAffiliation);
MucUserItem presenceItem = new MucUserItem(target, null, newAffiliation, Role.None);
for (Occupant occupant : room.getOccupants()) {
StanzaBuilder builder = MUCStanzaBuilder.createMessageStanza(room.getJID(), occupant.getJid(), null, null);
builder.addPreparedElement(presenceItem);
relayStanza(occupant.getJid(), builder.build(), serverRuntimeContext);