Search code examples
iosxmppxmppframework

XMPP Unknown Message Format


I'm new to XMPP. I do receive messages with the body but I'm also receiving many of them without a body.
I'm preparing a demo for the iOS platform.

What kind of messages are these and in what way it's helpful?

<?xml version="1.0" encoding="UTF-8"?>
<message xmlns="jabber:client" to="[email protected]/iPhone" from="[email protected]">
   <result xmlns="urn:xmpp:mam:1" id="1596108476932101">
      <forwarded xmlns="urn:xmpp:forward:0">
         <message xmlns="jabber:client" lang="en" to="[email protected]/converse.js-6910592" from="[email protected]/converse.js-69153543" type="chat" id="id9c6b26dd-50dc-467c-a436-dd1e16af05fe">
            <archived xmlns="urn:xmpp:mam:tmp" by="[email protected]" id="1596108476932101" />
            <stanza-id xmlns="urn:xmpp:sid:0" by="[email protected]" id="1596108476932101" />
            <received xmlns="urn:xmpp:receipts" id="idcb348164-9a0b-4b9b-b351-03c97341fe91" />
            <store xmlns="urn:xmpp:hints" />
         </message>
         <delay xmlns="urn:xmpp:delay" from="xmpp.server.io" stamp="2020-07-30T11:27:56.932101Z" />
      </forwarded>
   </result>
</message>

Solution

  • This is a message that comes from the message archive (a pretty old implementation as it still uses <archived/> elements which have been used in 2013 and were removed just one year later).

    The outer message (id=1596108476932101) is the carrier message which is used to forward the inner, archived message to you. The inner message (id=id9c6b26dd-50dc-467c-a436-dd1e16af05fe) contains a delivery receipt (<received/>) that tells your contact [email protected] that another earlier message (id=idcb348164-9a0b-4b9b-b351-03c97341fe91) has been received successfully.

    So basically the whole construct is a MAM query result containing an archived message that carries a ´` marker.

    While this particular message is not very useful for you, archived messages without body could come in handy in some situations, so you should not ignore all of them. For example archived messages containing chat markers could be used to sync up which messages have been read by any of your clients.