Changeset

9032:029e1e18d65c

mod_pubsub: Add support for owner subscription retrieval https://xmpp.org/extensions/xep-0060.html#owner-subscriptions-retrieve
author Kim Alvefur <zash@zash.se>
date Fri, 13 Jul 2018 04:42:19 +0200
parents 9031:d1a4b1b78695
children 9033:f1b6efd5b379
files plugins/mod_pubsub/pubsub.lib.lua
diffstat 1 files changed, 17 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/mod_pubsub/pubsub.lib.lua	Fri Jul 13 04:41:59 2018 +0200
+++ b/plugins/mod_pubsub/pubsub.lib.lua	Fri Jul 13 04:42:19 2018 +0200
@@ -250,6 +250,23 @@
 	return true;
 end
 
+function handlers.owner_get_subscriptions(origin, stanza, subscriptions, service)
+	local node = subscriptions.attr.node;
+	local ok, ret = service:get_subscriptions(node, stanza.attr.from);
+	if not ok then
+		origin.send(pubsub_error_reply(stanza, ret));
+		return true;
+	end
+	local reply = st.reply(stanza)
+		:tag("pubsub", { xmlns = xmlns_pubsub_owner })
+			:tag("subscriptions");
+	for _, sub in ipairs(ret) do
+		reply:tag("subscription", { node = sub.node, jid = sub.jid, subscription = 'subscribed' }):up();
+	end
+	origin.send(reply);
+	return true;
+end
+
 function handlers.set_create(origin, stanza, create, service)
 	local node = create.attr.node;
 	local ok, ret, reply;