}
private void sendNewOccupantPresenceToExisting(Occupant newOccupant, Occupant existingOccupant, Room room, ServerRuntimeContext serverRuntimeContext) {
Entity roomAndNewUserNick = new EntityImpl(room.getJID(), newOccupant.getName());
StanzaBuilder builder = StanzaBuilder.createPresenceStanza(roomAndNewUserNick, existingOccupant.getJid(), null, null, null, null);
List<XMLElement> inner = new ArrayList<XMLElement>();
// room is non-anonymous or semi-anonmoys and the occupant a moderator, send full user JID
boolean includeJid = room.getRoomTypes().contains(RoomType.NonAnonymous) ||
(room.getRoomTypes().contains(RoomType.SemiAnonymous) && existingOccupant.getRole() == Role.Moderator);
inner.add(new Item(newOccupant, includeJid, false));
if(existingOccupant.getJid().equals(newOccupant.getJid())) {
if(room.getRoomTypes().contains(RoomType.NonAnonymous)) {
// notify the user that this is a non-anonymous room
inner.add(new Status(StatusCode.ROOM_NON_ANONYMOUS));
}
// send status to indicate that this is the users own presence
inner.add(new Status(StatusCode.OWN_PRESENCE));
}
builder.addPreparedElement(new X(NamespaceURIs.XEP0045_MUC_USER, inner));
logger.debug("Room presence from {} sent to {}", roomAndNewUserNick, existingOccupant);
relayStanza(existingOccupant.getJid(), builder.build(), serverRuntimeContext);
}