aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/mod_pubsub
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
commit8942bafa1a3be077f3dece4f8f49f9d08375f11d (patch)
treec3ba662f78420a52589a7ea903a2ccdc1c37c7eb /plugins/mod_pubsub
parent97644a718986fc2c8b7377f10a30f9b260cde255 (diff)
downloadprosody-8942bafa1a3be077f3dece4f8f49f9d08375f11d.tar.gz
prosody-8942bafa1a3be077f3dece4f8f49f9d08375f11d.zip
mod_pubsub: Add support for retrieving subscription options
Diffstat (limited to 'plugins/mod_pubsub')
-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