diff options
author | Matthew Wild <mwild1@gmail.com> | 2018-10-18 18:00:54 +0100 |
---|---|---|
committer | Matthew Wild <mwild1@gmail.com> | 2018-10-18 18:00:54 +0100 |
commit | 44b3954d56045498adc788ca9517c33b4e56cb54 (patch) | |
tree | 722220336b9d73b1ab178b657a0cad807bdf1aca /util/pubsub.lua | |
parent | dd2f749996583ed2aba09906d83541718f4c8ecf (diff) | |
download | prosody-44b3954d56045498adc788ca9517c33b4e56cb54.tar.gz prosody-44b3954d56045498adc788ca9517c33b4e56cb54.zip |
util.pubsub: Allow publishing with a config that should be used as defaults only
Diffstat (limited to 'util/pubsub.lua')
-rw-r--r-- | util/pubsub.lua | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/util/pubsub.lua b/util/pubsub.lua index cb21174f..45a5aab6 100644 --- a/util/pubsub.lua +++ b/util/pubsub.lua @@ -493,7 +493,7 @@ local function check_preconditions(node_config, required_config) return true; end -function service:publish(node, actor, id, item, required_config) --> ok, err +function service:publish(node, actor, id, item, requested_config) --> ok, err -- Access checking local may_publish = false; @@ -516,13 +516,16 @@ function service:publish(node, actor, id, item, required_config) --> ok, err if not self.config.autocreate_on_publish then return false, "item-not-found"; end - local ok, err = self:create(node, true, required_config); + local ok, err = self:create(node, true, requested_config); if not ok then return ok, err; end node_obj = self.nodes[node]; - elseif required_config and not check_preconditions(node_obj.config, required_config) then - return false, "precondition-not-met"; + elseif requested_config and not requested_config._defaults_only then + -- Check that node has the requested config before we publish + if not check_preconditions(node_obj.config, requested_config) then + return false, "precondition-not-met"; + end end if not self.config.itemcheck(item) then return nil, "invalid-item"; |