aboutsummaryrefslogtreecommitdiffstats
path: root/util/pubsub.lua
diff options
context:
space:
mode:
Diffstat (limited to 'util/pubsub.lua')
-rw-r--r--util/pubsub.lua13
1 files changed, 13 insertions, 0 deletions
diff --git a/util/pubsub.lua b/util/pubsub.lua
index a24b04f2..0f31423d 100644
--- a/util/pubsub.lua
+++ b/util/pubsub.lua
@@ -36,6 +36,10 @@ local function save_node_to_store(service, node)
});
end
+local function delete_node_in_store(service, node_name)
+ return service.config.nodestore:set(node_name, nil);
+end
+
-- Create and return a new service object
local function new(config)
config = config or {};
@@ -290,6 +294,15 @@ function service:delete(node, actor)
self.data[node]:clear();
end
self.data[node] = nil;
+
+ if self.config.nodestore then
+ local ok, err = delete_node_in_store(self, node);
+ if not ok then
+ self.nodes[node] = nil;
+ return ok, err;
+ end
+ end
+
self.events.fire_event("node-deleted", { node = node, actor = actor });
self.config.broadcaster("delete", node, node_obj.subscribers, nil, actor, node_obj, self);
return true;