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 ...@@ -49,7 +49,7 @@ public class XmppResultSet
catch (NumberFormatException e) catch (NumberFormatException e)
{ {
if (setElement.elementText("before").isEmpty()) { if (setElement.elementText("before").isEmpty()) {
this.before = Long.valueOf(9223372036854775807L); this.before = Long.MAX_VALUE;
} }
} }
catch (Exception e) catch (Exception e)
......
...@@ -61,7 +61,10 @@ public class IQRetrieveHandler extends AbstractIQHandler { ...@@ -61,7 +61,10 @@ public class IQRetrieveHandler extends AbstractIQHandler {
fromIndex = resultSet.getAfter().intValue() + 1; fromIndex = resultSet.getAfter().intValue() + 1;
toIndex = fromIndex + max; toIndex = fromIndex + max;
} else if (resultSet.getBefore() != null) { } else if (resultSet.getBefore() != null) {
if (resultSet.getBefore()!=Long.MAX_VALUE)
toIndex = resultSet.getBefore().intValue(); toIndex = resultSet.getBefore().intValue();
else
toIndex = conversation.getMessages().size();
fromIndex = toIndex - max; fromIndex = toIndex - max;
} }
} }
...@@ -76,10 +79,12 @@ public class IQRetrieveHandler extends AbstractIQHandler { ...@@ -76,10 +79,12 @@ public class IQRetrieveHandler extends AbstractIQHandler {
addMessageElement(chatElement, conversation, message); addMessageElement(chatElement, conversation, message);
} }
if (resultSet != null && messages.size() > 0) { if (resultSet != null) {
if (messages.size() > 0) {
resultSet.setFirst((long) fromIndex); resultSet.setFirst((long) fromIndex);
resultSet.setFirstIndex(fromIndex); resultSet.setFirstIndex(fromIndex);
resultSet.setLast((long) toIndex - 1); resultSet.setLast((long) toIndex - 1);
}
resultSet.setCount(conversation.getMessages().size()); resultSet.setCount(conversation.getMessages().size());
chatElement.add(resultSet.createResultElement()); chatElement.add(resultSet.createResultElement());
} }
......
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