aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorJonas Wielicki <jonas@wielicki.name>2018-08-05 11:44:49 +0200
committerJonas Wielicki <jonas@wielicki.name>2018-08-05 11:44:49 +0200
commit56b0cd35c6768193b5c237c176339f176b73f1a2 (patch)
tree786a7eab965d6e51391be30376a047c19beddfb8 /plugins
parent3c1fedd6d76f4e1b8be21471ab462cbd741665d3 (diff)
downloadprosody-56b0cd35c6768193b5c237c176339f176b73f1a2.tar.gz
prosody-56b0cd35c6768193b5c237c176339f176b73f1a2.zip
pubsub.lib: auto-create node with publish-options if autocreation is enabled
Diffstat (limited to 'plugins')
-rw-r--r--plugins/mod_pubsub/pubsub.lib.lua14
1 files changed, 12 insertions, 2 deletions
diff --git a/plugins/mod_pubsub/pubsub.lib.lua b/plugins/mod_pubsub/pubsub.lib.lua
index 3fcf5255..1fd5a39e 100644
--- a/plugins/mod_pubsub/pubsub.lib.lua
+++ b/plugins/mod_pubsub/pubsub.lib.lua
@@ -552,8 +552,18 @@ function handlers.set_publish(origin, stanza, publish, service)
-- Ensure that the node configuration matches the values in publish-options
local publish_options_form = publish_options:get_child("x", "jabber:x:data");
local required_config = config_from_xep0060(node_config_form:data(publish_options_form), true);
- local node_config = service:get_node_config(node, stanza.attr.from);
- if not check_preconditions(node_config, required_config) then
+ local node_accessible, node_config = service:get_node_config(node, stanza.attr.from);
+ if node_accessible == false and service.config.autocreate_on_publish then
+ module:log("debug", "creating node %s with publish-options", node)
+ -- we need to create the node here so that it is configured
+ -- correctly
+ local created, err = service:create(node, stanza.attr.from, required_config)
+ if not created then
+ local reply = pubsub_error_reply(stanza, err);
+ origin.send(reply);
+ return true;
+ end
+ elseif not check_preconditions(node_config, required_config) then
local reply = pubsub_error_reply(stanza, "precondition-not-met");
origin.send(reply);
return true;