aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/mod_pubsub/pubsub.lib.lua
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2018-07-14 19:35:26 +0200
committerKim Alvefur <zash@zash.se>2018-07-14 19:35:26 +0200
commitd870120a2fd7884c3cfe64af41a3d009af2fafb8 (patch)
treec3ba662f78420a52589a7ea903a2ccdc1c37c7eb /plugins/mod_pubsub/pubsub.lib.lua
parent6a42be3086d9ad4135bd36ac8a65709260b802fa (diff)
downloadprosody-d870120a2fd7884c3cfe64af41a3d009af2fafb8.tar.gz
prosody-d870120a2fd7884c3cfe64af41a3d009af2fafb8.zip
mod_pubsub: Add support for retrieving subscription options
Diffstat (limited to 'plugins/mod_pubsub/pubsub.lib.lua')
-rw-r--r--plugins/mod_pubsub/pubsub.lib.lua20
1 files changed, 20 insertions, 0 deletions
diff --git a/plugins/mod_pubsub/pubsub.lib.lua b/plugins/mod_pubsub/pubsub.lib.lua
index 5cabdf00..5bebbeba 100644
--- a/plugins/mod_pubsub/pubsub.lib.lua
+++ b/plugins/mod_pubsub/pubsub.lib.lua
@@ -433,6 +433,26 @@ function handlers.set_unsubscribe(origin, stanza, unsubscribe, service)
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