# HG changeset patch # User Kim Alvefur # Date 1531589726 -7200 # Node ID e993fad0cc62bde1ef67ec01251d5af57aa4510d # Parent 0124e5ec1556af098241dbcf43080ecdcbe6d799 mod_pubsub: Add support for retrieving subscription options diff -r 0124e5ec1556 -r e993fad0cc62 plugins/mod_pubsub/pubsub.lib.lua --- a/plugins/mod_pubsub/pubsub.lib.lua Sat Jul 14 19:34:10 2018 +0200 +++ b/plugins/mod_pubsub/pubsub.lib.lua Sat Jul 14 19:35:26 2018 +0200 @@ -433,6 +433,26 @@ return true; end +function handlers.get_options(origin, stanza, options, service) + local node, jid = options.attr.node, options.attr.jid; + jid = jid_prep(jid); + if not (node and jid) then + origin.send(pubsub_error_reply(stanza, jid and "nodeid-required" or "invalid-jid")); + return true; + end + local ok, ret = service:get_subscription(node, stanza.attr.from, jid); + if not ok then + origin.send(pubsub_error_reply(stanza, "not-subscribed")); + return true; + end + if ret == true then ret = {} end + origin.send(st.reply(stanza) + :tag("pubsub", { xmlns = xmlns_pubsub }) + :tag("options", { node = node, jid = jid }) + :add_child(options_form:form(ret))); + return true; +end + function handlers.set_publish(origin, stanza, publish, service) local node = publish.attr.node; if not node then