igniterealtime/openfire-monitoring-plugin

MAM doesn't include `complete` attribute on "urn:xmpp:mam:2" query with <fin/> when result is empty.

Closed this issue · 2 comments

(Migrated from https://issues.igniterealtime.org/browse/OF-2063)

When querying MAM archive of a MUC room and when there aren't any items left and is return it lacks complete attribute:

https://xmpp.org/extensions/xep-0313.html#query-paging-request

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'.

 
Example:

Request

<iq type='set' to='smack@conference.igniterealtime.org' id='AC4C54D1-261C-40E6-BC82-5F2C6DD64B3E'>
<query xmlns='urn:xmpp:mam:2' queryid='A747F17C-B623-493E-B93B-E0C60CC822A2'>
<x type='submit' xmlns='jabber:x:data'>
<field type='hidden' var='FORM_TYPE'>
<value>urn:xmpp:mam:2</value>
</field>
<field type='text-single' var='start'>
<value>2020-07-30T20:54:48Z</value>
</field>
<field type='text-single' var='end'>
<value>2020-08-03T16:02:16Z</value>
</field>
</x>
<set xmlns='http://jabber.org/protocol/rsm'>
<max>150</max>
</set>
</query>
</iq>

Response (lacking complete attribute):

<iq to='wojtek@tigase.org/1505915227-tigase-19' from='openfire@conference.igniterealtime.org' id='1B867B69-40BE-4EDA-A68A-D6CFA7E0F99E' type='result' xmlns='jabber:client'>
<fin queryid='B60B9A76-9E13-4C43-8D0D-B30E15C807E3' xmlns='urn:xmpp:mam:2'>
<set xmlns='http://jabber.org/protocol/rsm'>
<count>0</count>
</set>
</fin>
</iq>

I believe that this issue is limited to cases where the returned result set is completely empty (<count>0</count>):

For this request, which asks for a maximum of 150 elements, but returns 50, the complete attribute is present:

<iq type='set' to='smack@conference.igniterealtime.org' id='AC4C54D1-261C-40E6-BC82-5F2C6DD64B3E'>
<query xmlns='urn:xmpp:mam:2' queryid='A747F17C-B623-493E-B93B-E0C60CC822A2'>
<x type='submit' xmlns='jabber:x:data'>
<field type='hidden' var='FORM_TYPE'>
<value>urn:xmpp:mam:2</value>
</field>
<field type='text-single' var='start'>
<value>2020-07-30T02:54:48Z</value>
</field>
<field type='text-single' var='end'>
<value>2020-08-03T16:02:16Z</value>
</field>
</x>
<set xmlns='http://jabber.org/protocol/rsm'>
<max>150</max>
</set>
</query>
</iq>

Response (with complete):

<iq type="result" id="AC4C54D1-261C-40E6-BC82-5F2C6DD64B3E" from="smack@conference.igniterealtime.org">
  <fin xmlns="urn:xmpp:mam:2" queryid="A747F17C-B623-493E-B93B-E0C60CC822A2" complete="true">
    <set xmlns="http://jabber.org/protocol/rsm">
      <first>
        d6164b3d-7364-4df7-aba7-2d00c7d86463
      </first>
      <last>
        58488f66-ecd2-4a81-a1a1-90bc343a320f
      </last>
      <count>
        50
      </count>
    </set>
  </fin>
</iq>

Thanks for reporting this issue, @woj-tek