aboutsummaryrefslogtreecommitdiffstats
path: root/util/pubsub.lua
diff options
context:
space:
mode:
authorFlorian Zeitz <florob@babelmonkeys.de>2013-01-25 01:32:14 +0100
committerFlorian Zeitz <florob@babelmonkeys.de>2013-01-25 01:32:14 +0100
commit4196cca0e08cb9c3404f8b10db51714d1abc0286 (patch)
tree3607f9b61fa33d68c4fd61c89b49d602332b150f /util/pubsub.lua
parent0767f241531940a9a66eb4be285ee26cd44b57a0 (diff)
downloadprosody-4196cca0e08cb9c3404f8b10db51714d1abc0286.tar.gz
prosody-4196cca0e08cb9c3404f8b10db51714d1abc0286.zip
mod_pubsub, util.pubsub: Don't send purge notifications in an <items/> element
Diffstat (limited to 'util/pubsub.lua')
-rw-r--r--util/pubsub.lua27
1 files changed, 18 insertions, 9 deletions
diff --git a/util/pubsub.lua b/util/pubsub.lua
index 17795cf1..c77140b9 100644
--- a/util/pubsub.lua
+++ b/util/pubsub.lua
@@ -245,7 +245,7 @@ function service:publish(node, actor, id, item)
end
node_obj.data[id] = item;
self.events.fire_event("item-published", { node = node, actor = actor, id = id, item = item });
- self.config.broadcaster(node, node_obj.subscribers, item);
+ self.config.broadcaster("items", node, node_obj.subscribers, item);
return true;
end
@@ -259,19 +259,28 @@ function service:retract(node, actor, id, retract)
if (not node_obj) or (not node_obj.data[id]) then
return false, "item-not-found";
end
- if id then
- node_obj.data[id] = nil;
- else
- node_obj.data = {}; -- Purge
- end
+ node_obj.data[id] = nil;
if retract then
- self.config.broadcaster(node, node_obj.subscribers, retract);
+ self.config.broadcaster("items", node, node_obj.subscribers, retract);
end
return true
end
-function service:purge(node, actor, purge)
- return self:retract(node, actor, nil, purge);
+function service:purge(node, actor, notify)
+ -- Access checking
+ if not self:may(node, actor, "retract") then
+ return false, "forbidden";
+ end
+ --
+ local node_obj = self.nodes[node];
+ if not node_obj then
+ return false, "item-not-found";
+ end
+ node_obj.data = {}; -- Purge
+ if notify then
+ self.config.broadcaster("purge", node, node_obj.subscribers);
+ end
+ return true
end
function service:get_items(node, actor, id)