igniterealtime/openfire-monitoring-plugin

All messages returned when using RSM max=0 and the embedded database

Closed this issue · 2 comments

When:

  • Openfire is configured to use the internal HSQL embedded database, and
  • I query the archive using max=0 to return only the count

Then:

  • All messages are returned followed by the IQ containing the count.

Expected:

  • Just the IQ containing the count (see XEP-0059)

Example query:

<iq to="chat@conference.example.org" id="test1" type="set">
    <query xmlns='urn:xmpp:mam:2' queryid='00001'>
        <x xmlns='jabber:x:data' type='submit'>
            <field var='FORM_TYPE'>
                <value>urn:xmpp:mam:2</value>
            </field>
            <field var='start'>
                <value>2020-01-20T00:00:00.000+00:00</value>
            </field>
        </x>
        <set xmlns='http://jabber.org/protocol/rsm'>
            <max>0</max>
        </set>
    </query>
</iq>```

This appears to be due to a bug in HSQLDB, which seems to disregard a LIMIT clause, if the number that follows is 0 (it works fine for positive numbers).

Fix in the referenced commit now returns the result as expected from the XEP ✅