igniterealtime/openfire-monitoring-plugin

Last element not returned when RSM page size is set to 1

Closed this issue · 1 comments

When I run this query to return all messages, 1 at a time, the element isn't returned

Query:
<iq xmlns='jabber:client' id='ZIMR2-28' type='set'><query xmlns='urn:xmpp:mam:2' queryid='6SIH-7U9D-RYDG-5'><x xmlns='jabber:x:data' type='submit'><field var='FORM_TYPE'><value>urn:xmpp:mam:2</value></field></x><set xmlns='http://jabber.org/protocol/rsm'><max>1</max></set></query></iq>

Response
<iq xmlns='jabber:client' to='user3@xmpp2.localhost.example/7rhmjkqkmg' from='user3@xmpp2.localhost.example' id='ZIMR2-28' type='result'><fin xmlns='urn:xmpp:mam:2' queryid='6SIH-7U9D-RYDG-5' stable='true'><set xmlns='http://jabber.org/protocol/rsm'><count>3</count><first>1</first></set></fin></iq>

Setting the page size to 2 doesn't exhibit the same problem:

Query
<iq xmlns='jabber:client' id='ZIMR2-28' type='set'><query xmlns='urn:xmpp:mam:2' queryid='6SIH-7U9D-RYDG-5'><x xmlns='jabber:x:data' type='submit'><field var='FORM_TYPE'><value>urn:xmpp:mam:2</value></field></x><set xmlns='http://jabber.org/protocol/rsm'><max>2</max></set></query></iq>

Response
<iq xmlns='jabber:client' to='user3@xmpp2.localhost.example/7rhmjkqkmg' from='user3@xmpp2.localhost.example' id='ZIMR2-28' type='result'><fin xmlns='urn:xmpp:mam:2' queryid='6SIH-7U9D-RYDG-5' stable='true'><set xmlns='http://jabber.org/protocol/rsm'><count>3</count><first>1</first><last>2</last></set></fin></iq>

This bug prevents me from using Smack's MamManager to paginate

The code adds 'last' only when the result set has more than one entry in it. That's easily changed!