3
votes

I am using eJabberd server (MAM enabled) with client library Strophe.js. Client app is storing fixed amount of the messages in local storage.

All the messages, that I receive from the server include elements <archived/> and <stanza-id/>, which provide server-side generated IDs:

<message 
    xmlns="jabber:client" to="[email protected]/8667085700924567016834" from="[email protected]">
    <result 
        xmlns="urn:xmpp:mam:2" id="1520510373346685">
        <forwarded 
            xmlns="urn:xmpp:forward:0">
            <message 
                xmlns="jabber:client" xml:lang="en" to="[email protected]" from="[email protected]/60965696931000870402419" type="chat">
                <archived 
                    xmlns="urn:xmpp:mam:tmp" by="[email protected]" id="1520510373346685"/>
                <stanza-id 
                    xmlns="urn:xmpp:sid:0" by="[email protected]" id="1520510373346685"/>
                <body>asdf</body>
            </message>
            <delay 
                xmlns="urn:xmpp:delay" from="example.net" stamp="2018-03-08T11:59:33.346685Z"/>
        </forwarded>
    </result>
</message>

I use these IDs to get fixed amount of messages on each MAM call (using RSM paging - before/after/max attributes). For example:

params = {
    "before": "1520510373346685",
    "max": 10,
    onMessage: <some handler>,
    onComplete: <some handler>,
}
this.connection.mam.query(Strophe.getBareJidFromJid(this.myJid), params);

This gets me 10 messages before the message with stanza-id 1520510373346685.

However, the messages I send inherently do not have this ID, until I send them and retrieve from MAM.

I did not find any examples on getting the currently sent message ID from the server, and the Strophe does not provide any callbacks after the message was sent from the client and received by the server.

So, the question - is there any way to get the server-generated message ID (stanza-id/archived) for the currently sent message?

Maybe my own approach is wrong - should I generate my own IDs and add it to each message from the client?

1

1 Answers

2
votes

There is currently no mechanism specified besides querying the archive. One prominent idea within the XMPP community to solve this in the future is to reflect the send carbon back to the original sender, which would include a stanza-id element with the ID assigned by the archive.