aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/mod_pubsub
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2018-08-06 08:21:55 +0100
committerMatthew Wild <mwild1@gmail.com>2018-08-06 08:21:55 +0100
commit96509275b883522d8a16bed56c998a2a2fe0424f (patch)
tree8a905f8eee3e7772c11f811003d310094f78d6a2 /plugins/mod_pubsub
parent56b0cd35c6768193b5c237c176339f176b73f1a2 (diff)
parent27bbd90669cf314d6945892456e4ed0a20590302 (diff)
downloadprosody-96509275b883522d8a16bed56c998a2a2fe0424f.tar.gz
prosody-96509275b883522d8a16bed56c998a2a2fe0424f.zip
Merge with jonasw
Diffstat (limited to 'plugins/mod_pubsub')
-rw-r--r--plugins/mod_pubsub/mod_pubsub.lua6
-rw-r--r--plugins/mod_pubsub/pubsub.lib.lua19
2 files changed, 15 insertions, 10 deletions
diff --git a/plugins/mod_pubsub/mod_pubsub.lua b/plugins/mod_pubsub/mod_pubsub.lua
index 113ee2b3..25b5192d 100644
--- a/plugins/mod_pubsub/mod_pubsub.lua
+++ b/plugins/mod_pubsub/mod_pubsub.lua
@@ -150,6 +150,10 @@ local function get_affiliation(jid)
end
end
+function get_service()
+ return service;
+end
+
function set_service(new_service)
service = new_service;
module.environment.service = service;
@@ -196,6 +200,7 @@ function module.load()
publish = true;
retract = true;
get_nodes = true;
+ get_configuration = true;
subscribe = true;
unsubscribe = true;
@@ -220,6 +225,7 @@ function module.load()
delete = true;
get_nodes = true;
configure = true;
+ get_configuration = true;
subscribe = true;
unsubscribe = true;
diff --git a/plugins/mod_pubsub/pubsub.lib.lua b/plugins/mod_pubsub/pubsub.lib.lua
index 1fd5a39e..e6c6fd6f 100644
--- a/plugins/mod_pubsub/pubsub.lib.lua
+++ b/plugins/mod_pubsub/pubsub.lib.lua
@@ -642,18 +642,12 @@ function handlers.owner_get_configure(origin, stanza, config, service)
return true;
end
- if not service:may(node, stanza.attr.from, "configure") then
- origin.send(pubsub_error_reply(stanza, "forbidden"));
- return true;
- end
-
- local node_obj = service.nodes[node];
- if not node_obj then
- origin.send(pubsub_error_reply(stanza, "item-not-found"));
+ local ok, node_config = service:get_node_config(node, stanza.attr.from);
+ if not ok then
+ origin.send(pubsub_error_reply(stanza, node_config));
return true;
end
- local node_config = node_obj.config;
local pubsub_form_data = config_to_xep0060(node_config);
local reply = st.reply(stanza)
:tag("pubsub", { xmlns = xmlns_pubsub_owner })
@@ -678,7 +672,12 @@ function handlers.owner_set_configure(origin, stanza, config, service)
origin.send(st.error_reply(stanza, "modify", "bad-request", "Missing dataform"));
return true;
end
- local form_data, err = node_config_form:data(config_form);
+ local ok, old_config = service:get_node_config(node, stanza.attr.from);
+ if not ok then
+ origin.send(pubsub_error_reply(stanza, old_config));
+ return true;
+ end
+ local form_data, err = node_config_form:data(config_form, old_config);
if not form_data then
origin.send(st.error_reply(stanza, "modify", "bad-request", err));
return true;