Getting latest items from XMPP PubSub Node using Smack always only returns one item

I am using the latest Smack (4.1) for my android app.

When fetching persistent items from a node, does it only return the most recently posted items for each user? Right now, when I try to call getItems, I only seem to get the last posted event from each user. I would like to get all the elements from a node even if there is more than one element for each user.

This is the code I'm currently using to extract:

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 config:

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 posts two items to a node and then calls getItems, only the last of their published items will be retrieved. Debugging shows that I only get 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="afa@example.com/Smack" id="4cw4Z-27" type="result">  
   <pubsub xmlns="http://jabber.org/protocol/pubsub">  
      <items node="TESTNODE">  
         <item id="bool@example.com/Smack">  
            <newevent xmlns="http://jabber.org/protocol/newevent" xml:lang="en">  
               <sender>bool@example.com</sender>  
               <title>Test Title 2</title>  
               <description>Test description</description>  
            </newevent>  
         </item>  
      </items>  
   </pubsub>  
</iq>  

      

This is the only thing I get in debugging. No other items other than the last one posted for this specific user and other users.

Clearly I am getting the items stored in a node, however the server only returns the last posted item for each user. I would like to get all the items posted to a node regardless of whether it is the last one for that user or not.

Is this a server setup issue? I appreciate any advice or suggestions. Thank!

+3


source to share


2 answers


I have set the JID of the payload item to the JID of the user. As a result, I overwritten the previous ID and the previous messages from the user were overwritten. I have set the ItemLailItemItyleName to null and the server will generate a unique ID each time so the previous items will not be overwritten.



+1


source


This could be a server limitation. XEP-60 6.5.7 provides max_items

additional functionality.



+1


source







All Articles