Comparison

util/pubsub.lua @ 5305:391b72fede9f

mod_pubsub, util.pubsub: Implement the purge action
author Kim Alvefur <zash@zash.se>
date Thu, 24 Jan 2013 00:58:03 +0100
parent 5181:1e9508ae44cc
child 5312:fdcd2ac7c22d
comparison
equal deleted inserted replaced
5304:67a49d47ef39 5305:391b72fede9f
257 -- 257 --
258 local node_obj = self.nodes[node]; 258 local node_obj = self.nodes[node];
259 if (not node_obj) or (not node_obj.data[id]) then 259 if (not node_obj) or (not node_obj.data[id]) then
260 return false, "item-not-found"; 260 return false, "item-not-found";
261 end 261 end
262 node_obj.data[id] = nil; 262 if id then
263 node_obj.data[id] = nil;
264 else
265 node_obj.data = {}; -- Purge
266 end
263 if retract then 267 if retract then
264 self.config.broadcaster(node, node_obj.subscribers, retract); 268 self.config.broadcaster(node, node_obj.subscribers, retract);
265 end 269 end
266 return true 270 return true
271 end
272
273 function service:purge(node, actor, purge)
274 return self:retract(node, actor, nil, purge);
267 end 275 end
268 276
269 function service:get_items(node, actor, id) 277 function service:get_items(node, actor, id)
270 -- Access checking 278 -- Access checking
271 if not self:may(node, actor, "get_items") then 279 if not self:may(node, actor, "get_items") then