Software /
code /
prosody
Comparison
plugins/mod_pubsub/pubsub.lib.lua @ 9120:01fc8ba0a7fa
mod_pubsub: Use util.pubsub API for retrieving node config instead
Normalizes access control to the 'get_configuration' capability
Thanks pep.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sun, 05 Aug 2018 19:12:49 +0200 |
parent | 9116:9f36f5c14545 |
child | 9122:a69dc9c729ec |
comparison
equal
deleted
inserted
replaced
9119:5444d4a8ad90 | 9120:01fc8ba0a7fa |
---|---|
630 if not node then | 630 if not node then |
631 origin.send(pubsub_error_reply(stanza, "nodeid-required")); | 631 origin.send(pubsub_error_reply(stanza, "nodeid-required")); |
632 return true; | 632 return true; |
633 end | 633 end |
634 | 634 |
635 if not service:may(node, stanza.attr.from, "configure") then | 635 local ok, node_config = service:get_node_config(node, stanza.attr.from); |
636 origin.send(pubsub_error_reply(stanza, "forbidden")); | 636 if not ok then |
637 return true; | 637 origin.send(pubsub_error_reply(stanza, node_config)); |
638 end | 638 return true; |
639 | 639 end |
640 local node_obj = service.nodes[node]; | 640 |
641 if not node_obj then | |
642 origin.send(pubsub_error_reply(stanza, "item-not-found")); | |
643 return true; | |
644 end | |
645 | |
646 local node_config = node_obj.config; | |
647 local pubsub_form_data = config_to_xep0060(node_config); | 641 local pubsub_form_data = config_to_xep0060(node_config); |
648 local reply = st.reply(stanza) | 642 local reply = st.reply(stanza) |
649 :tag("pubsub", { xmlns = xmlns_pubsub_owner }) | 643 :tag("pubsub", { xmlns = xmlns_pubsub_owner }) |
650 :tag("configure", { node = node }) | 644 :tag("configure", { node = node }) |
651 :add_child(node_config_form:form(pubsub_form_data)); | 645 :add_child(node_config_form:form(pubsub_form_data)); |