Software /
code /
prosody
Diff
util/pubsub.lua @ 5855:275d4da9404f
Merge 0.10->trunk
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Sat, 05 Oct 2013 12:16:28 -0400 |
parent | 5851:cdcfd93e2f43 |
child | 5973:905b4fd863b4 |
line wrap: on
line diff
--- a/util/pubsub.lua Sat Oct 05 12:15:25 2013 -0400 +++ b/util/pubsub.lua Sat Oct 05 12:16:28 2013 -0400 @@ -258,6 +258,7 @@ end node_obj = self.nodes[node]; end + node_obj.data[#node_obj.data + 1] = id; node_obj.data[id] = item; self.events.fire_event("item-published", { node = node, actor = actor, id = id, item = item }); self.config.broadcaster("items", node, node_obj.subscribers, item); @@ -275,6 +276,12 @@ return false, "item-not-found"; end node_obj.data[id] = nil; + for i, _id in ipairs(node_obj.data) do + if id == _id then + table.remove(node_obj, i); + break; + end + end if retract then self.config.broadcaster("items", node, node_obj.subscribers, retract); end @@ -309,7 +316,7 @@ return false, "item-not-found"; end if id then -- Restrict results to a single specific item - return true, { [id] = node_obj.data[id] }; + return true, { id, [id] = node_obj.data[id] }; else return true, node_obj.data; end