Software /
code /
prosody
Changeset
9040:e993fad0cc62
mod_pubsub: Add support for retrieving subscription options
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sat, 14 Jul 2018 19:35:26 +0200 |
parents | 9039:0124e5ec1556 |
children | 9041:b3bc742ee188 |
files | plugins/mod_pubsub/pubsub.lib.lua |
diffstat | 1 files changed, 20 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- 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