From a01a95ee9412b85f3ef6ef85c9cc5819ff33b951 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Fri, 17 Dec 2010 13:23:29 +0000 Subject: mod_pubsub: Handle disco#info and disco#items --- plugins/mod_pubsub.lua | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'plugins/mod_pubsub.lua') 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 }); -- cgit v1.2.3 From 07e945631dc2abe7a2afe204919a72d25398c687 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Fri, 17 Dec 2010 13:35:21 +0000 Subject: mod_pubsub: Preserve service object on module reload --- plugins/mod_pubsub.lua | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'plugins/mod_pubsub.lua') diff --git a/plugins/mod_pubsub.lua b/plugins/mod_pubsub.lua index 769dd49a..dc1b1263 100644 --- a/plugins/mod_pubsub.lua +++ b/plugins/mod_pubsub.lua @@ -195,3 +195,11 @@ service = pubsub.new({ }); module.environment.service = service; +function module.save() + return { service = service }; +end + +function module.restore(data) + service = data.service; + module.environment.service = service; +end -- cgit v1.2.3