Software /
code /
prosody
Comparison
plugins/mod_pubsub.lua @ 3880:2b736209bf21
mod_pubsub: Handle disco#info and disco#items
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Fri, 17 Dec 2010 13:23:29 +0000 |
parent | 3823:5bde3e9d78a7 |
child | 3761:e5fb26e8faeb |
comparison
equal
deleted
inserted
replaced
3879:f67427331d23 | 3880:2b736209bf21 |
---|---|
164 end | 164 end |
165 end | 165 end |
166 | 166 |
167 module:hook("iq/host/http://jabber.org/protocol/pubsub:pubsub", handle_pubsub_iq); | 167 module:hook("iq/host/http://jabber.org/protocol/pubsub:pubsub", handle_pubsub_iq); |
168 | 168 |
169 local disco_info = st.stanza("query", { xmlns = "http://jabber.org/protocol/disco#info" }) | |
170 :tag("identity", { category = "pubsub", type = "service" }):up() | |
171 :tag("feature", { var = "http://jabber.org/protocol/pubsub" }):up(); | |
172 | |
173 module:hook("iq-get/host/http://jabber.org/protocol/disco#info:query", function (event) | |
174 event.origin.send(st.reply(event.stanza):add_child(disco_info)); | |
175 return true; | |
176 end); | |
177 | |
178 module:hook("iq-get/host/http://jabber.org/protocol/disco#items:query", function (event) | |
179 local ok, ret = service:get_nodes(event.stanza.attr.from); | |
180 if not ok then | |
181 event.origin.send(pubsub_error_reply(stanza, ret)); | |
182 else | |
183 local reply = st.reply(event.stanza) | |
184 :tag("query", { xmlns = "http://jabber.org/protocol/disco#items" }); | |
185 for node, node_obj in pairs(ret) do | |
186 reply:tag("item", { jid = module.host, node = node, name = node_obj.config.name }):up(); | |
187 end | |
188 event.origin.send(reply); | |
189 end | |
190 return true; | |
191 end); | |
192 | |
169 service = pubsub.new({ | 193 service = pubsub.new({ |
170 broadcaster = simple_broadcast | 194 broadcaster = simple_broadcast |
171 }); | 195 }); |
172 module.environment.service = service; | 196 module.environment.service = service; |
173 | 197 |