aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/mod_pubsub.lua
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2010-12-17 13:50:33 +0000
committerMatthew Wild <mwild1@gmail.com>2010-12-17 13:50:33 +0000
commit8ee0fb71fcba10a54760d4a047a4a91e2ab97ad1 (patch)
tree08ff2f81be281c7d1f399e2e3ff5b74f1671b77b /plugins/mod_pubsub.lua
parentc1efda1ffd82e6988ab20b4be5f75ecf31fb551e (diff)
parent07e945631dc2abe7a2afe204919a72d25398c687 (diff)
downloadprosody-8ee0fb71fcba10a54760d4a047a4a91e2ab97ad1.tar.gz
prosody-8ee0fb71fcba10a54760d4a047a4a91e2ab97ad1.zip
Merge Tobias->trunk
Diffstat (limited to 'plugins/mod_pubsub.lua')
-rw-r--r--plugins/mod_pubsub.lua32
1 files changed, 32 insertions, 0 deletions
diff --git a/plugins/mod_pubsub.lua b/plugins/mod_pubsub.lua
index 0953de28..dc1b1263 100644
--- a/plugins/mod_pubsub.lua
+++ b/plugins/mod_pubsub.lua
@@ -166,8 +166,40 @@ 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
});
module.environment.service = service;
+function module.save()
+ return { service = service };
+end
+
+function module.restore(data)
+ service = data.service;
+ module.environment.service = service;
+end