MamQueryArgs.queryLastPage() behaviour with afterUid

Hi,
I’m using Smack 4.4.5 and I’ve run into something I’d like to double-check.

My code:

val queryArgs = MamQueryArgs.builder()
    .setResultPageSize(30)
    .queryLastPage()
    .afterUid(archiveId)
    .build()

What I observe:

  • If there are messages after archiveId, I get the last page of those messages, as expected.

  • If there are no messages after archiveId, the query returns the last page of the archive, i.e. messages preceding archiveId.

I was expecting an empty result in that case (no messages after the anchor), but queryLastPage() seems to override that and always return the last available page.

Questions:

  1. Is this the intended behaviour according to MAM / Smack?

  2. Is there a way to ask for “last page only if there are results after afterUid, otherwise return nothing”?
    Or should queryLastPage() simply not be combined with an anchor?

Thanks!

That’s more a question for the XMPP protocol community than Smack. I think you are basically doing

<iq type='set' id='q29302'>
  <query xmlns='urn:xmpp:mam:2'>
    <set xmlns='http://jabber.org/protocol/rsm'>
      <after>archiveId</after>
      <before/>
    </set>
  </query>
</iq>

(note that before is the empty string)

I does not appear that the interaction between <after/> with value and <before/> without a value is properly specified. I suggest you ask for clarification on the XSF standards mailing list.

Yes, indeed, this is exactly what I am doing.
Thank you for your answer.