diff options
author | Kim Alvefur <zash@zash.se> | 2017-11-09 17:19:11 +0100 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2017-11-09 17:19:11 +0100 |
commit | f7d98fa513ffe143f8e0ba987d1a5b6a1d758103 (patch) | |
tree | 13b19772054df606dd0a0cf77ba363635270714f /util/pubsub.lua | |
parent | a957f6c038290ebec028cc6bda8edfcf1844a7a8 (diff) | |
download | prosody-f7d98fa513ffe143f8e0ba987d1a5b6a1d758103.tar.gz prosody-f7d98fa513ffe143f8e0ba987d1a5b6a1d758103.zip |
util.pubsub: Recreate itemstore if persist_items changes or resize it if max_items changes
Diffstat (limited to 'util/pubsub.lua')
-rw-r--r-- | util/pubsub.lua | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/util/pubsub.lua b/util/pubsub.lua index 8122e2f2..607ec49d 100644 --- a/util/pubsub.lua +++ b/util/pubsub.lua @@ -431,14 +431,14 @@ function service:set_node_config(node, actor, new_config) return false, "item-not-found"; end - for k,v in pairs(new_config) do - node_obj.config[k] = v; - end - local new_data = self.config.itemstore(self.nodes[node].config, node); - for key, value in self.data[node]:items() do - new_data:set(key, value); + if new_config["persist_items"] ~= node_obj.config["persist_items"] then + self.data[node] = self.config.itemstore(self.nodes[node].config, node); + elseif new_config["max_items"] ~= node_obj.config["max_items"] then + self.data[node]:resize(new_config["max_items"]); end - self.data[node] = new_data; + + node_obj.config = setmetatable(new_config, {__index=self.node_defaults}); + return true; end |