Software / code / prosody
Comparison
plugins/mod_pubsub/pubsub.lib.lua @ 9817:7aad9eb7f050 0.11
mod_pubsub: Support requests for multiple items (fixes #1305)
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Mon, 28 Jan 2019 01:41:42 +0100 |
| parent | 9274:1712e366b081 |
| child | 10062:6ffed67356e9 |
comparison
equal
deleted
inserted
replaced
| 9816:7f84d7f77a00 | 9817:7aad9eb7f050 |
|---|---|
| 293 end | 293 end |
| 294 end | 294 end |
| 295 | 295 |
| 296 function handlers.get_items(origin, stanza, items, service) | 296 function handlers.get_items(origin, stanza, items, service) |
| 297 local node = items.attr.node; | 297 local node = items.attr.node; |
| 298 local item = items:get_child("item"); | 298 |
| 299 local item_id = item and item.attr.id; | 299 local requested_items = {}; |
| 300 for item in items:childtags("item") do | |
| 301 table.insert(requested_items, item.attr.id); | |
| 302 end | |
| 303 if requested_items[1] == nil then | |
| 304 requested_items = nil; | |
| 305 end | |
| 300 | 306 |
| 301 if not node then | 307 if not node then |
| 302 origin.send(pubsub_error_reply(stanza, "nodeid-required")); | 308 origin.send(pubsub_error_reply(stanza, "nodeid-required")); |
| 303 return true; | 309 return true; |
| 304 end | 310 end |
| 305 local ok, results = service:get_items(node, stanza.attr.from, item_id); | 311 local ok, results = service:get_items(node, stanza.attr.from, requested_items); |
| 306 if not ok then | 312 if not ok then |
| 307 origin.send(pubsub_error_reply(stanza, results)); | 313 origin.send(pubsub_error_reply(stanza, results)); |
| 308 return true; | 314 return true; |
| 309 end | 315 end |
| 310 | 316 |