aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2018-08-05 15:17:00 +0200
committerKim Alvefur <zash@zash.se>2018-08-05 15:17:00 +0200
commit2b8327099ad7aa5db62cccb1e4381d394b5519e3 (patch)
tree8afe8cb868fee93d5b80fce443e63bb8feb6348c
parent9c75dbe8a8c7c575f0b91af37a0fcea71c883492 (diff)
downloadprosody-2b8327099ad7aa5db62cccb1e4381d394b5519e3.tar.gz
prosody-2b8327099ad7aa5db62cccb1e4381d394b5519e3.zip
util.pubsub: Apply defaults metatable before config check (thanks pep.)
Makes it so that the callback sees the default if it’s not in the form, which makes it easier to validate.
-rw-r--r--util/pubsub.lua4
1 files changed, 3 insertions, 1 deletions
diff --git a/util/pubsub.lua b/util/pubsub.lua
index 381c449a..964b26c7 100644
--- a/util/pubsub.lua
+++ b/util/pubsub.lua
@@ -565,6 +565,8 @@ function service:set_node_config(node, actor, new_config)
return false, "item-not-found";
end
+ setmetatable(new_config, {__index=self.node_defaults})
+
if self.config.check_node_config then
local ok = self.config.check_node_config(node, actor, new_config);
if not ok then
@@ -573,7 +575,7 @@ function service:set_node_config(node, actor, new_config)
end
local old_config = node_obj.config;
- node_obj.config = setmetatable(new_config, {__index=self.node_defaults});
+ node_obj.config = new_config;
if self.config.nodestore then
local ok, err = save_node_to_store(self, node_obj);