Software /
code /
prosody
Comparison
plugins/mod_pubsub/pubsub.lib.lua @ 9131:d0d676b86013
pubsub.lib: Enable publish-options unconditionally
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Mon, 06 Aug 2018 11:25:31 +0100 |
parent | 9130:74525b8104d5 |
child | 9136:07fc2c5c0c2e |
comparison
equal
deleted
inserted
replaced
9130:74525b8104d5 | 9131:d0d676b86013 |
---|---|
9 local dataform = require"util.dataforms".new; | 9 local dataform = require"util.dataforms".new; |
10 | 10 |
11 local xmlns_pubsub = "http://jabber.org/protocol/pubsub"; | 11 local xmlns_pubsub = "http://jabber.org/protocol/pubsub"; |
12 local xmlns_pubsub_errors = "http://jabber.org/protocol/pubsub#errors"; | 12 local xmlns_pubsub_errors = "http://jabber.org/protocol/pubsub#errors"; |
13 local xmlns_pubsub_owner = "http://jabber.org/protocol/pubsub#owner"; | 13 local xmlns_pubsub_owner = "http://jabber.org/protocol/pubsub#owner"; |
14 | |
15 local enable_publish_options = module:get_option_boolean("enable_publish_options", true); | |
16 | 14 |
17 local _M = {}; | 15 local _M = {}; |
18 | 16 |
19 local handlers = {}; | 17 local handlers = {}; |
20 _M.handlers = handlers; | 18 _M.handlers = handlers; |
196 create = { "create-nodes", "instant-nodes", "item-ids", "create-and-configure" }; | 194 create = { "create-nodes", "instant-nodes", "item-ids", "create-and-configure" }; |
197 delete = { "delete-nodes" }; | 195 delete = { "delete-nodes" }; |
198 get_items = { "retrieve-items" }; | 196 get_items = { "retrieve-items" }; |
199 get_subscriptions = { "retrieve-subscriptions" }; | 197 get_subscriptions = { "retrieve-subscriptions" }; |
200 node_defaults = { "retrieve-default" }; | 198 node_defaults = { "retrieve-default" }; |
201 publish = { "publish", "multi-items", enable_publish_options and "publish-options" or nil }; | 199 publish = { "publish", "multi-items", "publish-options" }; |
202 purge = { "purge-nodes" }; | 200 purge = { "purge-nodes" }; |
203 retract = { "delete-items", "retract-items" }; | 201 retract = { "delete-items", "retract-items" }; |
204 set_node_config = { "config-node" }; | 202 set_node_config = { "config-node" }; |
205 set_affiliation = { "modify-affiliations" }; | 203 set_affiliation = { "modify-affiliations" }; |
206 }; | 204 }; |
561 if not node then | 559 if not node then |
562 origin.send(pubsub_error_reply(stanza, "nodeid-required")); | 560 origin.send(pubsub_error_reply(stanza, "nodeid-required")); |
563 return true; | 561 return true; |
564 end | 562 end |
565 local publish_options = stanza.tags[1]:get_child("publish-options"); | 563 local publish_options = stanza.tags[1]:get_child("publish-options"); |
566 if enable_publish_options and publish_options then | 564 if publish_options then |
567 -- Ensure that the node configuration matches the values in publish-options | 565 -- Ensure that the node configuration matches the values in publish-options |
568 local publish_options_form = publish_options:get_child("x", "jabber:x:data"); | 566 local publish_options_form = publish_options:get_child("x", "jabber:x:data"); |
569 local required_config = config_from_xep0060(node_config_form:data(publish_options_form), true); | 567 local required_config = config_from_xep0060(node_config_form:data(publish_options_form), true); |
570 local node_accessible, node_config = service:get_node_config(node, stanza.attr.from); | 568 local node_accessible, node_config = service:get_node_config(node, stanza.attr.from); |
571 if node_accessible == false and service.config.autocreate_on_publish then | 569 if node_accessible == false and service.config.autocreate_on_publish then |