Software /
code /
prosody
Comparison
plugins/mod_pubsub/pubsub.lib.lua @ 9125:da7a2db01d6a
Merge with jonasw
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Mon, 06 Aug 2018 08:21:55 +0100 |
parent | 9124:dcc490f0044d |
parent | 9122:a69dc9c729ec |
child | 9126:3dd5034a3233 |
comparison
equal
deleted
inserted
replaced
9124:dcc490f0044d | 9125:da7a2db01d6a |
---|---|
640 if not node then | 640 if not node then |
641 origin.send(pubsub_error_reply(stanza, "nodeid-required")); | 641 origin.send(pubsub_error_reply(stanza, "nodeid-required")); |
642 return true; | 642 return true; |
643 end | 643 end |
644 | 644 |
645 if not service:may(node, stanza.attr.from, "configure") then | 645 local ok, node_config = service:get_node_config(node, stanza.attr.from); |
646 origin.send(pubsub_error_reply(stanza, "forbidden")); | 646 if not ok then |
647 return true; | 647 origin.send(pubsub_error_reply(stanza, node_config)); |
648 end | 648 return true; |
649 | 649 end |
650 local node_obj = service.nodes[node]; | 650 |
651 if not node_obj then | |
652 origin.send(pubsub_error_reply(stanza, "item-not-found")); | |
653 return true; | |
654 end | |
655 | |
656 local node_config = node_obj.config; | |
657 local pubsub_form_data = config_to_xep0060(node_config); | 651 local pubsub_form_data = config_to_xep0060(node_config); |
658 local reply = st.reply(stanza) | 652 local reply = st.reply(stanza) |
659 :tag("pubsub", { xmlns = xmlns_pubsub_owner }) | 653 :tag("pubsub", { xmlns = xmlns_pubsub_owner }) |
660 :tag("configure", { node = node }) | 654 :tag("configure", { node = node }) |
661 :add_child(node_config_form:form(pubsub_form_data)); | 655 :add_child(node_config_form:form(pubsub_form_data)); |
676 local config_form = config:get_child("x", "jabber:x:data"); | 670 local config_form = config:get_child("x", "jabber:x:data"); |
677 if not config_form then | 671 if not config_form then |
678 origin.send(st.error_reply(stanza, "modify", "bad-request", "Missing dataform")); | 672 origin.send(st.error_reply(stanza, "modify", "bad-request", "Missing dataform")); |
679 return true; | 673 return true; |
680 end | 674 end |
681 local form_data, err = node_config_form:data(config_form); | 675 local ok, old_config = service:get_node_config(node, stanza.attr.from); |
676 if not ok then | |
677 origin.send(pubsub_error_reply(stanza, old_config)); | |
678 return true; | |
679 end | |
680 local form_data, err = node_config_form:data(config_form, old_config); | |
682 if not form_data then | 681 if not form_data then |
683 origin.send(st.error_reply(stanza, "modify", "bad-request", err)); | 682 origin.send(st.error_reply(stanza, "modify", "bad-request", err)); |
684 return true; | 683 return true; |
685 end | 684 end |
686 local new_config = config_from_xep0060(form_data); | 685 local new_config = config_from_xep0060(form_data); |