From e18193a4ffec3a0f8351827823a04425e7956a39 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Fri, 13 Jul 2018 04:42:19 +0200 Subject: mod_pubsub: Add support for owner subscription retrieval https://xmpp.org/extensions/xep-0060.html#owner-subscriptions-retrieve --- plugins/mod_pubsub/pubsub.lib.lua | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/plugins/mod_pubsub/pubsub.lib.lua b/plugins/mod_pubsub/pubsub.lib.lua index 0fadd6e7..f10c593f 100644 --- a/plugins/mod_pubsub/pubsub.lib.lua +++ b/plugins/mod_pubsub/pubsub.lib.lua @@ -250,6 +250,23 @@ function handlers.get_subscriptions(origin, stanza, subscriptions, service) 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; -- cgit v1.2.3