Software /
code /
prosody
Changeset
13550:eae0272b87e3
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.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Fri, 08 Nov 2024 02:12:45 +0100 |
parents | 13549:3b357ab6b6eb |
children | 13551:e17ff906d71b |
files | plugins/mod_pubsub/mod_pubsub.lua plugins/mod_pubsub/pubsub.lib.lua |
diffstat | 2 files changed, 16 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- a/plugins/mod_pubsub/mod_pubsub.lua Fri Nov 08 02:11:00 2024 +0100 +++ b/plugins/mod_pubsub/mod_pubsub.lua Fri Nov 08 02:12:45 2024 +0100 @@ -256,6 +256,13 @@ 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;
--- a/plugins/mod_pubsub/pubsub.lib.lua Fri Nov 08 02:11:00 2024 +0100 +++ b/plugins/mod_pubsub/pubsub.lib.lua Fri Nov 08 02:12:45 2024 +0100 @@ -290,27 +290,20 @@ 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)