diff plugins/pubsub.js @ 90:c1566c6981e5 master

Pubsub configure stanza and method
author Sonny Piers <sonny.piers@gmail.com>
date Wed, 29 Feb 2012 19:13:40 +0100
parents 55548845b177
children 7affe7ac8fc7
line wrap: on
line diff
--- a/plugins/pubsub.js
+++ b/plugins/pubsub.js
@@ -64,6 +64,14 @@
         iq += "</pubsub></iq>";
         return iq;
       },
+      setConfig: function(aTo, aNode, aFields) {
+        var iq = "<iq type='set' to='" + aTo + "'><pubsub xmlns='" + Lightstring.ns.pubsub_owner + "'><configure node='" + aNode + "'><x xmlns='" + Lightstring.ns.x + "' type='submit'>";
+        aFields.forEach(function(field) {
+          iq += field;
+        });
+        iq += "</x></configure></pubsub></iq>";
+        return iq;
+      },
       setAffiliations: function(aTo, aNode, aAffiliations) {
         var iq = "<iq type='set' to='" + aTo + "'><pubsub xmlns='" + Lightstring.ns.pubsub_owner + "'><affiliations node='" + aNode + "'>";
         for (var i = 0; i < aAffiliations.length; i++)
@@ -99,6 +107,9 @@
       create: function(aTo, aNode, aFields, aResult, aError) {
         this.send(Lightstring.stanzas.pubsub.create(aTo, aNode, aFields), aResult, aError);
       },
+      configure: function(aTo, aNode, aFields, aResult, aError) {
+        this.send(Lightstring.stanzas.pubsub.setConfig(aTo, aNode, aFields), aResult, aError);
+      },
       config: function(aTo, aNode, aResult, aError) {
         this.send(Lightstring.stanzas.pubsub.getConfig(aTo, aNode), function(stanza) {
           //FIXME: wtf?