Commit fbede6ab authored by Roman S's avatar Roman S

Merge pull request #247 from ishmakov/master

Fix collection requests XEP-0059
parents 0e1ad53c 5beaf97c
......@@ -49,7 +49,7 @@ public class XmppResultSet
catch (NumberFormatException e)
{
if (setElement.elementText("before").isEmpty()) {
this.before = Long.valueOf(9223372036854775807L);
this.before = Long.MAX_VALUE;
}
}
catch (Exception e)
......
......@@ -61,7 +61,10 @@ public class IQRetrieveHandler extends AbstractIQHandler {
fromIndex = resultSet.getAfter().intValue() + 1;
toIndex = fromIndex + max;
} else if (resultSet.getBefore() != null) {
toIndex = resultSet.getBefore().intValue();
if (resultSet.getBefore()!=Long.MAX_VALUE)
toIndex = resultSet.getBefore().intValue();
else
toIndex = conversation.getMessages().size();
fromIndex = toIndex - max;
}
}
......@@ -76,12 +79,14 @@ public class IQRetrieveHandler extends AbstractIQHandler {
addMessageElement(chatElement, conversation, message);
}
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());
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());
}
return reply;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment