From e32aba4c5379e98d40e7f1a73dbb172f5a30c151 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Fri, 8 Nov 2024 02:12:45 +0100 Subject: mod_pubsub: Use new metadata method No longer bypasses access control to retrieve this config subset, which is also explicitly named in the service config now. --- plugins/mod_pubsub/mod_pubsub.lua | 7 +++++++ plugins/mod_pubsub/pubsub.lib.lua | 25 +++++++++---------------- 2 files changed, 16 insertions(+), 16 deletions(-) (limited to 'plugins') diff --git a/plugins/mod_pubsub/mod_pubsub.lua b/plugins/mod_pubsub/mod_pubsub.lua index 6efc419f..c17d9e63 100644 --- a/plugins/mod_pubsub/mod_pubsub.lua +++ b/plugins/mod_pubsub/mod_pubsub.lua @@ -256,6 +256,13 @@ function module.load() broadcaster = simple_broadcast; itemcheck = is_item_stanza; check_node_config = check_node_config; + metadata_subset = { + "title"; + "description"; + "payload_type"; + "access_model"; + "publish_model"; + }; get_affiliation = get_affiliation; jid = module.host; diff --git a/plugins/mod_pubsub/pubsub.lib.lua b/plugins/mod_pubsub/pubsub.lib.lua index 5a9be149..92586518 100644 --- a/plugins/mod_pubsub/pubsub.lib.lua +++ b/plugins/mod_pubsub/pubsub.lib.lua @@ -290,27 +290,20 @@ end function _M.handle_disco_info_node(event, service) local stanza, reply, node = event.stanza, event.reply, event.node; - local ok, ret = service:get_nodes(stanza.attr.from); + local ok, meta = service:get_node_metadata(node, stanza.attr.from); if not ok then - event.origin.send(pubsub_error_reply(stanza, ret)); - return true; - end - local node_obj = ret[node]; - if not node_obj then - event.origin.send(pubsub_error_reply(stanza, "item-not-found")); + event.origin.send(pubsub_error_reply(stanza, meta)); return true; end event.exists = true; reply:tag("identity", { category = "pubsub", type = "leaf" }):up(); - if node_obj.config then - reply:add_child(node_metadata_form:form({ - ["pubsub#title"] = node_obj.config.title; - ["pubsub#description"] = node_obj.config.description; - ["pubsub#type"] = node_obj.config.payload_type; - ["pubsub#access_model"] = node_obj.config.access_model; - ["pubsub#publish_model"] = node_obj.config.publish_model; - }, "result")); - end + reply:add_child(node_metadata_form:form({ + ["pubsub#title"] = meta.title; + ["pubsub#description"] = meta.description; + ["pubsub#type"] = meta.payload_type; + ["pubsub#access_model"] = meta.access_model; + ["pubsub#publish_model"] = meta.publish_model; + }, "result")); end function _M.handle_disco_items_node(event, service) -- cgit v1.2.3