private void processSendingInvitationMessage(
        @Nonnull final Message packet,
        @Nonnull final MUCRoom room,
        @Nonnull final MUCOccupant preExistingOccupantData )
    {
        Log.trace("Processing an invitation message from occupant '{}' to room '{}'.", packet.getFrom(), room.getName());
        try
        {
            final Element userInfo = packet.getChildElement("x", "http://jabber.org/protocol/muc#user");

            // Try to keep the list of extensions sent together with the message invitation. These extensions will be sent to the invitees.
            final List<Element> extensions = new ArrayList<>(packet.getElement().elements());
            extensions.remove(userInfo);

            // Send invitations to invitees
            final Iterator<Element> it = userInfo.elementIterator("invite");
            while ( it.hasNext() )
            {
                Element info = it.next();
                JID jid = new JID(info.attributeValue("to"));

                // Add the user as a member of the room if the room is members only
                if (room.isMembersOnly())
                {
                    room.addMember(jid, null, preExistingOccupantData.getAffiliation());
                }

                // Send the invitation to the invitee
                room.sendInvitation(jid, info.elementTextTrim("reason"), preExistingOccupantData.getAffiliation(), preExistingOccupantData.getUserAddress(), extensions);
            }
        }
        catch ( ForbiddenException e )
        {
            Log.debug("Rejecting invitation message from occupant '{}' in room '{}': Invitations are not allowed, or occupant is not allowed to modify the member list.", packet.getFrom(), room.getName(), e);
            sendErrorPacket(packet, PacketError.Condition.forbidden, "This room disallows invitations to be sent, or you're not allowed to modify the member list of this room.");
        }
        catch ( ConflictException e )
        {
            Log.debug("Rejecting invitation message from occupant '{}' in room '{}'.", packet.getFrom(), room.getName(), e);
            sendErrorPacket(packet, PacketError.Condition.conflict, "An unexpected exception occurred."); // TODO Is this code reachable?
        }
        catch ( CannotBeInvitedException e )
        {
            Log.debug("Rejecting invitation message from occupant '{}' in room '{}': The user being invited does not have access to the room.", packet.getFrom(), room.getName(), e);
            sendErrorPacket(packet, PacketError.Condition.not_acceptable, "The user being invited does not have access to the room.");
        }
    }
Process a room-invitation message sent by an occupant of the room.

@param packet                  The stanza to process
@param room                    The room that the stanza was addressed to.
@param preExistingOccupantData The occupant data of this user in the addressed room prior to processing of this stanza, if any.
xmppserver/src/main/java/org/jivesoftware/openfire/muc/spi/MultiUserChatServiceImpl.java