Software /
code /
prosody
Diff
plugins/mod_pubsub.lua @ 3765:0731e5432baa
Merge Tobias->trunk
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Fri, 17 Dec 2010 13:50:33 +0000 |
parent | 3761:e5fb26e8faeb |
child | 3908:4d8081c35f01 |
line wrap: on
line diff
--- a/plugins/mod_pubsub.lua Tue Dec 14 18:54:55 2010 +0100 +++ b/plugins/mod_pubsub.lua Fri Dec 17 13:50:33 2010 +0000 @@ -166,8 +166,40 @@ 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 }); module.environment.service = service; +function module.save() + return { service = service }; +end + +function module.restore(data) + service = data.service; + module.environment.service = service; +end