From abeade92134c64bc956bbbc382c2f64ba5d8b524 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sun, 5 Aug 2018 18:28:31 +0200 Subject: mod_pubsub: Add a public method for retrieving the service object There is already a set_service() --- plugins/mod_pubsub/mod_pubsub.lua | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'plugins') diff --git a/plugins/mod_pubsub/mod_pubsub.lua b/plugins/mod_pubsub/mod_pubsub.lua index 113ee2b3..21c43bce 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; -- cgit v1.2.3 From 9c54f104f112f925fd991bdf96b119001cc64a07 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sun, 5 Aug 2018 19:12:29 +0200 Subject: mod_pubsub: Add 'get_configuration' capability to relevant affiliations Like ca5228a7d907 did for mod_pep Thanks pep. --- plugins/mod_pubsub/mod_pubsub.lua | 2 ++ 1 file changed, 2 insertions(+) (limited to 'plugins') diff --git a/plugins/mod_pubsub/mod_pubsub.lua b/plugins/mod_pubsub/mod_pubsub.lua index 21c43bce..25b5192d 100644 --- a/plugins/mod_pubsub/mod_pubsub.lua +++ b/plugins/mod_pubsub/mod_pubsub.lua @@ -200,6 +200,7 @@ function module.load() publish = true; retract = true; get_nodes = true; + get_configuration = true; subscribe = true; unsubscribe = true; @@ -224,6 +225,7 @@ function module.load() delete = true; get_nodes = true; configure = true; + get_configuration = true; subscribe = true; unsubscribe = true; -- cgit v1.2.3 From 553b67ccd09ff5706194a1a7e7d75172948da6bf Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sun, 5 Aug 2018 19:12:49 +0200 Subject: mod_pubsub: Use util.pubsub API for retrieving node config instead Normalizes access control to the 'get_configuration' capability Thanks pep. --- plugins/mod_pubsub/pubsub.lib.lua | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) (limited to 'plugins') diff --git a/plugins/mod_pubsub/pubsub.lib.lua b/plugins/mod_pubsub/pubsub.lib.lua index 7c796c20..9c12572a 100644 --- a/plugins/mod_pubsub/pubsub.lib.lua +++ b/plugins/mod_pubsub/pubsub.lib.lua @@ -632,18 +632,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 }) -- cgit v1.2.3 From 27bbd90669cf314d6945892456e4ed0a20590302 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sun, 5 Aug 2018 15:52:19 +0200 Subject: mod_pubsub: Pass the current values to dataforms --- plugins/mod_pubsub/pubsub.lib.lua | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/mod_pubsub/pubsub.lib.lua b/plugins/mod_pubsub/pubsub.lib.lua index 9c12572a..adee989f 100644 --- a/plugins/mod_pubsub/pubsub.lib.lua +++ b/plugins/mod_pubsub/pubsub.lib.lua @@ -662,7 +662,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; -- cgit v1.2.3