Subject: Using MAM (XEP 313) to get user's conversation history
Howdy! I'm having trouble trying to figure out how to get all of the messages for a user. I tried using the code found in this forum: https://forum.ag-software.net/thread/1693-How-to-get-priva…
This didn't quite work for me. I received some errors claiming that the module was not supported. I tried to fashion my own query xml tag using the XEP-313 documentation found here: https://xmpp.org/extensions/xep-0313.html#query
This fixed the error and seems to return the correct data. My server responds with this:
What I am having trouble with is figuring out where this data is stored/sent after the library makes the query. I noticed that in your weather example, you have a response weather tag that comes inside of the IQ result. Then, you simply grab the weather tag out of it. My server doesn't do that. Is there some way I can grab onto all of the XML that my server is spitting back to me? If I could do that, then I could parse all of the messages out. Or, is there an easier way to do that?
Thank you ahead of time!
This didn't quite work for me. I received some errors claiming that the module was not supported. I tried to fashion my own query xml tag using the XEP-313 documentation found here: https://xmpp.org/extensions/xep-0313.html#query
- <iq type="set" id="MX_3" xmlns="jabber:client">
- <query xmlns="urn:xmpp:mam:2">
- <set xmlns="http://jabber.org/protocol/rsm">
- <max>1</max>
- </set>
- </query>
- </iq>
This fixed the error and seems to return the correct data. My server responds with this:
- <!-- Incoming 8/23/2018 4:41:10 PM -->
- <message to='user1@localhost/12141833377959589889731' from='user1@localhost'>
- <result id='1534864749939235' xmlns='urn:xmpp:mam:2'>
- <forwarded xmlns='urn:xmpp:forward:0'>
- <message xml:lang='en' to='user2@localhost' from='user1@localhost/2415766176799085569403' type='chat' id='purple28e6e12f' xmlns='jabber:client'>
- <archived by='user1@localhost' id='1534864749939235' xmlns='urn:xmpp:mam:tmp'/>
- <stanza-id by='user1@localhost' id='1534864749939235' xmlns='urn:xmpp:sid:0'/>
- <active xmlns='http://jabber.org/protocol/chatstates'/>
- <body>Hello?</body>
- </message>
- <delay from='localhost' stamp='2018-08-21T15:19:09.939235Z' xmlns='urn:xmpp:delay'/>
- </forwarded>
- </result>
- </message>
- <r xmlns='urn:xmpp:sm:3'/>
- <iq xml:lang='en' to='user1@localhost/12141833377959589889731' from='user1@localhost' type='result' id='MX_3'>
- <fin complete='false' xmlns='urn:xmpp:mam:2'>
- <set xmlns='http://jabber.org/protocol/rsm'>
- <count>33</count>
- <first>1534864749939235</first>
- <last>1534864749939235</last>
- </set>
- </fin>
- </iq>
What I am having trouble with is figuring out where this data is stored/sent after the library makes the query. I noticed that in your weather example, you have a response weather tag that comes inside of the IQ result. Then, you simply grab the weather tag out of it. My server doesn't do that. Is there some way I can grab onto all of the XML that my server is spitting back to me? If I could do that, then I could parse all of the messages out. Or, is there an easier way to do that?
Thank you ahead of time!