attribute 'complete' is always set to true
Closed this issue · 1 comments
Copied from https://discourse.igniterealtime.org/t/monitoring-archive-attribute-complete-is-always-set-to-true
A defect is that the attribute ‘complete’ always is set to “true”, although there are more messages found then returned and the number of messages has been limited by the maximum size of the result page.
<query xmlns='urn:xmpp:mam:2' >
<x xmlns='jabber:x:data' type='submit'>
<field var='FORM_TYPE' type='hidden'>
<value>urn:xmpp:mam:2</value>
</field>
<field var='start'>
<value>2019-09-29T11:11:40.928+00:00</value>
</field>
<field var='end'>
<value>2019-11-29T11:11:40.929+00:00</value>
</field>
</x>
<set xmlns='http://jabber.org/protocol/rsm'>
<max>2</max>
</set>
</query>
Return two messages and a ‘fin’ result:
<fin xmlns="urn:xmpp:mam:2" complete="true" stable="true">
<set xmlns="http://jabber.org/protocol/rsm">
<count>616</count>
<first>309e4431-c95d-46e8-8e59-9d3bab4f694c</first>
<last>d1576b86-30e1-4c44-a486-87ab3fc24b60</last>
</set>
</fin>
there are 616 messages which fit in the criteria, but only the first two are returned.
My assumption is that the following line is incorrect:
com.reucon.openfire.plugin.archive.impl.MucMamPersistenceManager.findMessages(Date, Date, String, String, XmppResultSet, boolean)
xmppResultSet.setComplete( msgs.size() <= maxResults );
should be
xmppResultSet.setComplete( totalCount <= maxResults );
The specification defines:
When the results returned by the server are complete (that is: when they have not been limited by the maximum size of the result page (either as specified or enforced by the server)), the server MUST include a 'complete' attribute on the element, with a value of 'true'; this informs the client that it doesn't need to perform further paging to retreive the requested data. If it is not the last page of the result set, the server MUST either omit the 'complete' attribute, or give it a value of 'false'.
This fix was suggested:
xmppResultSet.setComplete( totalCount <= maxResults );
That is an improvement, but I don't think it'll work properly with paginated responses. For paginated responses, only the last page can have complete
set to true
.