aboutsummaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2013-10-05 12:16:28 -0400
committerMatthew Wild <mwild1@gmail.com>2013-10-05 12:16:28 -0400
commit8754e4be8504fbdbdd796818d2ce68bb02e104e5 (patch)
tree9344408f15cd0951aad0c621076ac09fb81d539a /util
parentfa21be14b2c444aa7848c401e2be40bdd101e67a (diff)
parent841a59e0e13f566e3c2f324f8c54470dbec0e8e9 (diff)
downloadprosody-8754e4be8504fbdbdd796818d2ce68bb02e104e5.tar.gz
prosody-8754e4be8504fbdbdd796818d2ce68bb02e104e5.zip
Merge 0.10->trunk
Diffstat (limited to 'util')
-rw-r--r--util/pubsub.lua9
1 files changed, 8 insertions, 1 deletions
diff --git a/util/pubsub.lua b/util/pubsub.lua
index 0dfd196b..e0d428c0 100644
--- a/util/pubsub.lua
+++ b/util/pubsub.lua
@@ -258,6 +258,7 @@ function service:publish(node, actor, id, item)
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 @@ function service:retract(node, actor, id, retract)
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 @@ function service:get_items(node, actor, id)
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