Software /
code /
prosody
Comparison
plugins/mod_pubsub/pubsub.lib.lua @ 9124:dcc490f0044d
pubsub.lib: auto-create node with publish-options if autocreation is enabled
author | Jonas Wielicki <jonas@wielicki.name> |
---|---|
date | Sun, 05 Aug 2018 11:44:49 +0200 |
parent | 9123:5d5aa1c4fe34 |
child | 9125:da7a2db01d6a |
child | 9135:c68d62ae9cb7 |
comparison
equal
deleted
inserted
replaced
9123:5d5aa1c4fe34 | 9124:dcc490f0044d |
---|---|
550 local publish_options = stanza.tags[1]:get_child("publish-options"); | 550 local publish_options = stanza.tags[1]:get_child("publish-options"); |
551 if enable_publish_options and publish_options then | 551 if enable_publish_options and publish_options then |
552 -- Ensure that the node configuration matches the values in publish-options | 552 -- Ensure that the node configuration matches the values in publish-options |
553 local publish_options_form = publish_options:get_child("x", "jabber:x:data"); | 553 local publish_options_form = publish_options:get_child("x", "jabber:x:data"); |
554 local required_config = config_from_xep0060(node_config_form:data(publish_options_form), true); | 554 local required_config = config_from_xep0060(node_config_form:data(publish_options_form), true); |
555 local node_config = service:get_node_config(node, stanza.attr.from); | 555 local node_accessible, node_config = service:get_node_config(node, stanza.attr.from); |
556 if not check_preconditions(node_config, required_config) then | 556 if node_accessible == false and service.config.autocreate_on_publish then |
557 module:log("debug", "creating node %s with publish-options", node) | |
558 -- we need to create the node here so that it is configured | |
559 -- correctly | |
560 local created, err = service:create(node, stanza.attr.from, required_config) | |
561 if not created then | |
562 local reply = pubsub_error_reply(stanza, err); | |
563 origin.send(reply); | |
564 return true; | |
565 end | |
566 elseif not check_preconditions(node_config, required_config) then | |
557 local reply = pubsub_error_reply(stanza, "precondition-not-met"); | 567 local reply = pubsub_error_reply(stanza, "precondition-not-met"); |
558 origin.send(reply); | 568 origin.send(reply); |
559 return true; | 569 return true; |
560 end | 570 end |
561 end | 571 end |