changeset 96:646695bde8e9

better pubsub.items method
author Sonny Piers <sonny.piers@gmail.com>
date Thu, 03 May 2012 14:56:43 +0200
parents 7affe7ac8fc7
children 11e38a9bfe38
files plugins/pubsub.js
diffstat 1 files changed, 10 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/pubsub.js
+++ b/plugins/pubsub.js
@@ -34,8 +34,14 @@
       getConfig: function(aTo, aNode) {
         return  "<iq type='get' to='" + aTo + "'><pubsub xmlns='" + Lightstring.ns.pubsub_owner + "'><configure node='" + aNode + "'/></pubsub></iq>";
       },
-      items: function(aTo, aNode) {
-        return  "<iq type='get' to='" + aTo + "'><pubsub xmlns='" + Lightstring.ns.pubsub + "'><items node='" + aNode + "'/></pubsub></iq>";
+      items: function(aTo, aNode, aItems) {
+        var stanza =  "<iq type='get' to='" + aTo + "'><pubsub xmlns='" + Lightstring.ns.pubsub + "'><items node='" + aNode + "'>";
+        if (aItems) {
+          aItems.forEach(function(item) {
+            stanza += "<item id='" + item + "'/>"
+          });
+        }
+        return stanza + "</items></pubsub></iq>";
       },
       affiliations: function(aTo, aNode) {
         return "<iq type='get' to='" + aTo + "'><pubsub xmlns='" + Lightstring.ns.pubsub_owner + "'><affiliations node='" + aNode + "'/></pubsub></iq>";
@@ -81,8 +87,8 @@
       },
     },
     methods: {
-      items: function(aTo, aNode, aOnSuccess, aOnError) {
-        this.send(Lightstring.stanzas.pubsub.items(aTo, aNode), function(stanza) {
+      items: function(aTo, aNode, aItems, aOnSuccess, aOnError) {
+        this.send(Lightstring.stanzas.pubsub.items(aTo, aNode, aItems), function(stanza) {
           var items = stanza.DOM.querySelectorAll('item') || [];
           stanza.items = items;
           if (aOnSuccess)