aboutsummaryrefslogtreecommitdiffstats
path: root/util/pubsub.lua
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2018-07-01 04:46:37 +0200
committerKim Alvefur <zash@zash.se>2018-07-01 04:46:37 +0200
commitd61f5d7c910d778e33de87b90e204bb73b6a498e (patch)
tree026b65585794f1b62a797a20331d9ea6b4108f4a /util/pubsub.lua
parent6e786078206f8038256410f264fd95c5aa77e8db (diff)
downloadprosody-d61f5d7c910d778e33de87b90e204bb73b6a498e.tar.gz
prosody-d61f5d7c910d778e33de87b90e204bb73b6a498e.zip
util.pubsub: Remove node from persistent storage on deletion
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;