Reputation: 406
I'm using the latest Smack (4.1) for my Android application.
When retrieving persistent items from a node, does it only return the latest published items for each user? Right now, when I try to call getItems, I seem to only get the latest published event from each user. I would like to retrieve all of the items from the node, even if there's more than one item for each user.
This is the code I'm using currently for retrieval:
PubSubManager manager = new PubSubManager(connectionManager.getConnection());
node = manager.getNode(nodeList);
Collection<PayloadItem<EventItem>> eventItems = node.getItems(25);
Log.e(TAG, "Collection size: " + eventItems.size());
List<PayloadItem<EventItem>> payloadList = new ArrayList<>();
for(PayloadItem<EventItem> payload : eventItems) {
eventItemList.add(payload.getPayload());
}
This is my node configure form:
ConfigureForm configureForm = new ConfigureForm(DataForm.Type.submit);
configureForm.setAccessModel(AccessModel.open);
configureForm.setDeliverPayloads(true);
configureForm.setNotifyRetract(true);
configureForm.setPersistentItems(true);
configureForm.setPublishModel(PublishModel.open);
As you can tell, setPersistentItems is true. If one user submits two items to a node and then calls getItems, only the latest of their published items is received. The debug shows that I only receive the following:
<?xml version="1.0" encoding="UTF-8"?>
<iq to="pubsub.example.com" id="4cw4Z-27" type="get">
<pubsub xmlns="http://jabber.org/protocol/pubsub">
<items node="TESTNODE" max_items="25" />
</pubsub>
</iq>
<?xml version="1.0" encoding="UTF-8"?>
<iq from="pubsub.example.com" to="[email protected]/Smack" id="4cw4Z-27" type="result">
<pubsub xmlns="http://jabber.org/protocol/pubsub">
<items node="TESTNODE">
<item id="[email protected]/Smack">
<newevent xmlns="http://jabber.org/protocol/newevent" xml:lang="en">
<sender>[email protected]</sender>
<title>Test Title 2</title>
<description>Test description</description>
</newevent>
</item>
</items>
</pubsub>
</iq>
This is the only thing I receive in the debug. No other items present except for the latest published one for that particular user and other users.
It's clear that I am receiving the items stored in the node, however the server only returns the latest published item for each user. I would like to retrieve all items published to the node regardless if it's the latest one for that user or not.
Is this a server setting issue? I appreciate any advice or suggestions. Thanks!
Upvotes: 3
Views: 1235
Reputation: 406
I was setting the JID of the payload item to the User's JID. As a result, I was overwriting the previous ID's and the previous submissions from the user was being overwritten. I set the PayLoadItem's ItemID to null and that let the server generate a unique ID each time, so the previous items would not be overwritten.
Upvotes: 1
Reputation: 24063
This could possible be a server limitation. XEP-60 6.5.7 makes max_items
a optional feature.
Upvotes: 1