aboutsummaryrefslogtreecommitdiffstats
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
commit3d14011cf28b454d0243782e68d943b25f7c6013 (patch)
tree026b65585794f1b62a797a20331d9ea6b4108f4a
parentdcd5ebba7d00969b5673a49a5aaec56970508c27 (diff)
downloadprosody-3d14011cf28b454d0243782e68d943b25f7c6013.tar.gz
prosody-3d14011cf28b454d0243782e68d943b25f7c6013.zip
util.pubsub: Remove node from persistent storage on deletion
-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;