LocalMUCRoom::sendInvitation requires non-null reason to generate <invite> element for room invitations

FYI, just discovered that when trying to send an invitation from the room itself not providing the reason results in the element not being generated which in turn upsets smack’s InvitationListener - this is how I caught the case since other clients are happy with the older “jabber:x:conference” extension that is also being sent. Not sure if it’s the right behavior and XEP-0045 reads as if is always required for MUC invitations.

Cheers

package org.jivesoftware.openfire.muc.spi;

public void sendInvitation(JID to, String reason, MUCRole senderRole, List extensions)

throws ForbiddenException, CannotBeInvitedException {

// ChatUser will be null if the room itself (ie. via admin console) made the request

if (senderRole.getUserAddress() != null) {

frag.addElement(“invite”).addAttribute(“from”, senderRole.getUserAddress().toBareJID());

}

if (reason != null && reason.length() > 0) {

Element invite = frag.element(“invite”);

if (invite == null) {

invite = frag.addElement(“invite”);

}

invite.addElement(“reason”).setText(reason);

}

// ChatUser will be null if the room itself (ie. via admin console) made the request

if (senderRole.getUserAddress() != null) {

** frag.addElement(“invite”**).addAttribute(“from”, senderRole.getUserAddress().toBareJID());

}

if (reason != null && reason.length() > 0) {

Element invite = frag.element(“invite”);

if (invite == null) {

invite = frag.addElement(“invite”);

}

invite.addElement(“reason”).setText(reason);

}