1

I have gotten the last 10 messages from archive, and trying to get the 10 before that on request and so on.

On the XMPP doc. it said i set the before with my UID??

http://xmpp.org/extensions/xep-0059.html#backwards

<iq type='set' from='stpeter@jabber.org/roundabout' to='users.jabber.org' id='back1'>
  <query xmlns='jabber:iq:search'>
    <nick>Pete</nick>
    <set xmlns='http://jabber.org/protocol/rsm'>
      <max>10</max>
      <before>peter@pixyland.org</before>
    </set>
  </query>
</iq>

or this?? http://xmpp.org/extensions/xep-0313.html#query-paging

with some ID in the after tag? I am very confused, can anyone give me some pointer, thanks!

<iq type='set' id='q29303'>
  <query xmlns='urn:xmpp:mam:1'>
      <x xmlns='jabber:x:data' type='submit'>
        <field var='FORM_TYPE' type='hidden'><value>urn:xmpp:mam:1</value></field>>
        <field var='start'><value>2010-08-07T00:00:00Z</value></field>
      </x>
      <set xmlns='http://jabber.org/protocol/rsm'>
         <max>10</max>
         <after>09af3-cc343-b409f</after>
      </set>
  </query>
</iq>

I tried putting in before with my UID and it didnt work <before>peter@server.org</before>

ANd i have an error <error code='400' type='modify'><bad-request xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/></error></iq></body>

I am using strophe.js mam plugin and rsm plugin

John
  • 983
  • 1
  • 13
  • 31

1 Answers1

3

When you receive first page limited by RSM with max=10, you will receive first and last UIDs:

<iq type='result' id='q29302'>
  <fin xmlns='urn:xmpp:mam:1'>
    <set xmlns='http://jabber.org/protocol/rsm'>
      <first index='0'>28482-98726-73623</first>
      <last>09af3-cc343-b409f</last>
      <count>10</count>
    </set>
  </fin>
</iq>

These are UIDs of messages, which you can use in before and after subsequent queries.

unor
  • 92,415
  • 26
  • 211
  • 360
vitalyster
  • 4,980
  • 3
  • 19
  • 27
  • I am kind of getting it to work, but it is returning the results backwards.... and i am not getting a UID for the message but the count, so i am just putting those counts into the before and after.....not sure how to flip it backwards tho – John Jul 22 '16 at 05:07
  • Hi there @unor , i got an issue , i have messages 300 in a group , but the last UID which stream sending is not the value that i mentioned above. the value was like 100 or 130. when i tried to archive messages with tag, i'm unable to get messages. when i use after tag, i'm getting messages from First. like starting from 1st message.not before last message. Please help me in this issue. – Suresh Mopidevi May 03 '19 at 10:16
  • @SureshMopidevi: It’s not my answer :) -- Anyway, if vitalyster’s answer didn’t help in your case, and if your case is not exactly the same as John’s, I would suggest that you create a new question for this. – unor May 03 '19 at 10:22
  • Okay, i will @unor. – Suresh Mopidevi May 03 '19 at 10:38