mod_pubsub: Implement get_subscriptions

Wed, 22 Dec 2010 03:49:52 +0000

author
Matthew Wild <mwild1@gmail.com>
date
Wed, 22 Dec 2010 03:49:52 +0000
changeset 3941
526624f7852e
parent 3940
d55e67e4191a
child 3942
0323beb7183c

mod_pubsub: Implement get_subscriptions

plugins/mod_pubsub.lua file | annotate | diff | comparison | revisions
--- a/plugins/mod_pubsub.lua	Wed Dec 22 03:49:23 2010 +0000
+++ b/plugins/mod_pubsub.lua	Wed Dec 22 03:49:52 2010 +0000
@@ -67,6 +67,20 @@
 	return origin.send(reply);
 end
 
+function handlers.get_subscriptions(origin, stanza, subscriptions)
+	local node = subscriptions.attr.node;
+	local ok, ret = service:get_subscriptions(node, stanza.attr.from, stanza.attr.from);
+	if not ok then
+		return origin.send(pubsub_error_reply(stanza, ret));
+	end
+	local reply = st.reply(stanza)
+		:tag("subscriptions", { xmlns = xmlns_pubsub });
+	for _, sub in ipairs(ret) do
+		reply:tag("subscription", { node = sub.node, jid = sub.jid, subscription = 'subscribed' }):up();
+	end
+	return origin.send(reply);
+end
+
 function handlers.set_create(origin, stanza, create)
 	local node = create.attr.node;
 	local ok, ret, reply;

mercurial