Monitoring Plugin request collection count XEP-0059, XEP-0136

Request:

<iq type="get" id="page1">
     <retrieve xmlns="urn:xmpp:archive" with="room@app.shmakov.voximplant.com" start="2015-07-01T09:35:48.646Z">
          <set xmlns="http://jabber.org/protocol/rsm">
               <max>0</max>
          </set>
     </retrieve>
</iq>

Response: (invalid)

<iq type="result" id="page1" to="222(app.shmakov)@voximplant.com/QIP">
     <chat xmlns="urn:xmpp:archive" with="room@app.shmakov.voximplant.com" start="2015-07-01T09:35:48.646Z" />
</iq>

Should be valid

<iq type="result" id="page1" to="222(app.shmakov)@voximplant.com/QIP">
     <chat xmlns="urn:xmpp:archive" with="room@app.shmakov.voximplant.com" start="2015-07-01T09:35:48.646Z" />
         <set xmlns='http://jabber.org/protocol/rsm'>
              <count>100</count>
         </set>
</iq>

XEP-0059: Result Set Management

2.7 Getting the Item Count

In order to get the item count of a result set without retrieving the items themselves, the requesting entity simply specifies zero for the maximum size of the result set page:

Example 15. Requesting the Item Count

<iq type='set' from='stpeter@jabber.org/roundabout' to='users.jabber.org' id='count1'>
  <query xmlns='jabber:iq:search'>
    <nick>Pete</nick>
    <set xmlns='http://jabber.org/protocol/rsm'>
      <max>0</max>
    </set>
  </query>
</iq>
   

The responding entity then returns the item count, which MAY be approximate rather than precise if determining the exact number of items would be resource-intensive:

Example 16. Returning the Item Count

<iq type='result' from='users.jabber.org' to='stpeter@jabber.org/roundabout' id='count1'>
  <query xmlns='jabber:iq:search'>
    <set xmlns='http://jabber.org/protocol/rsm'>
      <count>800</count>
    </set>
  </query>
</iq>
   

Note: The element MAY be omitted, but only if it would be either impossible or exceptionally resource intensive to calculate reasonably accurate values.

Note: If there are no items in the full result set then the responding entity MUST return a response that adheres to the definition of the wrapper protocol (see Paging Forwards Through a Result Set).

To fix problem it’s should chage IQRetrieveHandler.java

public IQ handleIQ(IQ packet) method

if (resultSet != null && messages.size() > 0) {
  resultSet.setFirst((long) fromIndex);
  resultSet.setFirstIndex(fromIndex);
  resultSet.setLast((long) toIndex - 1);
  resultSet.setCount(conversation.getMessages().size());
  chatElement.add(resultSet.createResultElement());
}

to

if (resultSet != null) {
     if (messages.size() > 0) {
       resultSet.setFirst((long) fromIndex);
       resultSet.setFirstIndex(fromIndex);
       resultSet.setLast((long) toIndex - 1);
     }
     resultSet.setCount(conversation.getMessages().size());
     chatElement.add(resultSet.createResultElement());
}

Would you consider submitting a github pull request with that change?

I sent it to github pull request. I have also 3 changes for other problem with XEP-136 with using empty tag. Now i test it before sending request.

I am not finding the request, do you have a link to it?

Ups. Sent