From 8e27e5311a7b5589b7254afe10cbf5962547f25c Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sun, 25 Jul 2021 13:52:27 +0200 Subject: mod_pubsub: Respect 'expose publisher' setting in item retrieval --- plugins/mod_pubsub/mod_pubsub.lua | 1 + plugins/mod_pubsub/pubsub.lib.lua | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/mod_pubsub/mod_pubsub.lua b/plugins/mod_pubsub/mod_pubsub.lua index 19834ad4..6866312c 100644 --- a/plugins/mod_pubsub/mod_pubsub.lua +++ b/plugins/mod_pubsub/mod_pubsub.lua @@ -199,6 +199,7 @@ function module.load() set_service(pubsub.new({ autocreate_on_publish = autocreate_on_publish; autocreate_on_subscribe = autocreate_on_subscribe; + expose_publisher = expose_publisher; nodestore = node_store; itemstore = create_simple_itemstore; diff --git a/plugins/mod_pubsub/pubsub.lib.lua b/plugins/mod_pubsub/pubsub.lib.lua index 6214882f..c750ecb8 100644 --- a/plugins/mod_pubsub/pubsub.lib.lua +++ b/plugins/mod_pubsub/pubsub.lib.lua @@ -328,9 +328,16 @@ function handlers.get_items(origin, stanza, items, service) return true; end + local expose_publisher = service.config.expose_publisher; + local data = st.stanza("items", { node = node }); for _, id in ipairs(results) do - data:add_child(results[id]); + local item = results[id]; + if not expose_publisher then + item = st.clone(item); + item.attr.publisher = nil; + end + data:add_child(item); end local reply = st.reply(stanza) :tag("pubsub", { xmlns = xmlns_pubsub }) -- cgit v1.2.3