Mercurial > prosody-hg
comparison plugins/mod_pubsub.lua @ 3932:aa245e43b21e
mod_pubsub: Handle disco#items on nodes
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Wed, 22 Dec 2010 02:17:45 +0000 |
| parents | e288372dd19f |
| children | 24f0a7544a7a |
comparison
equal
deleted
inserted
replaced
| 3931:6daed692264f | 3932:aa245e43b21e |
|---|---|
| 217 module:hook("iq-get/host/http://jabber.org/protocol/disco#info:query", function (event) | 217 module:hook("iq-get/host/http://jabber.org/protocol/disco#info:query", function (event) |
| 218 event.origin.send(st.reply(event.stanza):add_child(disco_info)); | 218 event.origin.send(st.reply(event.stanza):add_child(disco_info)); |
| 219 return true; | 219 return true; |
| 220 end); | 220 end); |
| 221 | 221 |
| 222 local function handle_disco_items_on_node(event) | |
| 223 local stanza, origin = event.stanza, event.origin; | |
| 224 local query = stanza.tags[1]; | |
| 225 local node = query.attr.node; | |
| 226 local ok, ret = service:get_items(node, stanza.attr.from); | |
| 227 if not ok then | |
| 228 return origin.send(pubsub_error_reply(stanza, ret)); | |
| 229 end | |
| 230 | |
| 231 local reply = st.reply(stanza) | |
| 232 :tag("query", { xmlns = xmlns_disco_items }); | |
| 233 | |
| 234 for id, item in pairs(ret) do | |
| 235 reply:tag("item", { jid = module.host, name = id }); | |
| 236 end | |
| 237 | |
| 238 return origin.send(reply); | |
| 239 end | |
| 240 | |
| 241 | |
| 222 module:hook("iq-get/host/http://jabber.org/protocol/disco#items:query", function (event) | 242 module:hook("iq-get/host/http://jabber.org/protocol/disco#items:query", function (event) |
| 243 if event.stanza.tags[1].attr.node then | |
| 244 return handle_disco_items_on_node(event); | |
| 245 end | |
| 223 local ok, ret = service:get_nodes(event.stanza.attr.from); | 246 local ok, ret = service:get_nodes(event.stanza.attr.from); |
| 224 if not ok then | 247 if not ok then |
| 225 event.origin.send(pubsub_error_reply(stanza, ret)); | 248 event.origin.send(pubsub_error_reply(stanza, ret)); |
| 226 else | 249 else |
| 227 local reply = st.reply(event.stanza) | 250 local reply = st.reply(event.stanza) |
