Force "From" attribute in outgoing stanzas

Hi,

It seems like Smack removes ‘from’ attribute from all outgoing stanzas as per this issue https://issues.igniterealtime.org/browse/SMACK-547 .

Generally this behavior works fine, but I’m trying to implement a proposed extension ( https://docs.ejabberd.im/developer/proposed-extensions/muc-sub/ ) . Apparently ejabberd expects ‘from’ attribute in custom-iq stanza to function properly. Is there a way to force “from” attribute into a particular packet.

Here is my code:

public class MucSubIq extends IQ {...}
final MucSubIq mucSubIq = new MucSubIq(this.nick);
mucSubIq.setFrom(myXmppId);
mucSubIq.setTo(groupName);
mucSubIq.setType(IQ.Type.set);
Log.i(TAG,mucSubIq.toXML().toString());  //Prints: <iq to='temproom@conference.gappi.in' from='9739937980@gappi.in' id='M630P-12' type='set'>...</iq>
connection.sendStanza(mucSubIq); //Debug Output: SENT (0): <iq to='temproom@conference.gappi.in' id='M630P-12' type='set'>...</iq>

XMPP servers are required to stamp the from attribute of incoming stanzas received on c2s links. If it’s true what you are saying, then it’s an ejabberd bug and you should report it to the ejabberd developers.

Never the less you can use AbstractXMPPConnection (Smack 4.1.7 API) 's setFromMode() to change the Smack behavior.