diff options
author | Matthew Wild <mwild1@gmail.com> | 2010-12-17 13:23:29 +0000 |
---|---|---|
committer | Matthew Wild <mwild1@gmail.com> | 2010-12-17 13:23:29 +0000 |
commit | a01a95ee9412b85f3ef6ef85c9cc5819ff33b951 (patch) | |
tree | 69b61621defe73f45167abed7f00ecd3419aeef3 /plugins | |
parent | de79d047af80dc7b7310ef987e9c193f26a2167a (diff) | |
download | prosody-a01a95ee9412b85f3ef6ef85c9cc5819ff33b951.tar.gz prosody-a01a95ee9412b85f3ef6ef85c9cc5819ff33b951.zip |
mod_pubsub: Handle disco#info and disco#items
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/mod_pubsub.lua | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/plugins/mod_pubsub.lua b/plugins/mod_pubsub.lua index 0953de28..769dd49a 100644 --- a/plugins/mod_pubsub.lua +++ b/plugins/mod_pubsub.lua @@ -166,6 +166,30 @@ end module:hook("iq/host/http://jabber.org/protocol/pubsub:pubsub", handle_pubsub_iq); +local disco_info = st.stanza("query", { xmlns = "http://jabber.org/protocol/disco#info" }) + :tag("identity", { category = "pubsub", type = "service" }):up() + :tag("feature", { var = "http://jabber.org/protocol/pubsub" }):up(); + +module:hook("iq-get/host/http://jabber.org/protocol/disco#info:query", function (event) + event.origin.send(st.reply(event.stanza):add_child(disco_info)); + return true; +end); + +module:hook("iq-get/host/http://jabber.org/protocol/disco#items:query", function (event) + local ok, ret = service:get_nodes(event.stanza.attr.from); + if not ok then + event.origin.send(pubsub_error_reply(stanza, ret)); + else + local reply = st.reply(event.stanza) + :tag("query", { xmlns = "http://jabber.org/protocol/disco#items" }); + for node, node_obj in pairs(ret) do + reply:tag("item", { jid = module.host, node = node, name = node_obj.config.name }):up(); + end + event.origin.send(reply); + end + return true; +end); + service = pubsub.new({ broadcaster = simple_broadcast }); |