plugins.pubsub: implement node creation

Tue, 11 Oct 2011 13:26:11 +0200

author
Kim Alvefur <zash@zash.se>
date
Tue, 11 Oct 2011 13:26:11 +0200
changeset 221
efb4f60ba36e
parent 220
5e5af66b03fd
child 222
3c257afd68e7

plugins.pubsub: implement node creation

plugins/pubsub.lua file | annotate | diff | comparison | revisions
--- a/plugins/pubsub.lua	Sun Oct 02 00:30:12 2011 +0200
+++ b/plugins/pubsub.lua	Tue Oct 11 13:26:11 2011 +0200
@@ -27,6 +27,22 @@
 	return true;
 end
 
+function pubsub:create(server, node, callback)
+	local create = verse.iq({ to = server, type = "set" })
+		:tag("pubsub", { xmlns = xmlns_pubsub })
+			:tag("create", { node = node }):up()
+	self.stream:send_iq(create, function (result)
+		if callback then
+			if result.attr.type == "result" then
+				callback(true);
+			else
+				callback(false, result:get_error());
+			end
+		end
+	  end
+	);
+end
+
 function pubsub:subscribe(server, node, jid, callback)
 	self.stream:send_iq(verse.iq({ to = server, type = "set" })
 		:tag("pubsub", { xmlns = xmlns_pubsub })

mercurial