Changeset

11715:ddd6e21e58bf

mod_pubsub: Respect 'expose publisher' setting in item retrieval
author Kim Alvefur <zash@zash.se>
date Sun, 25 Jul 2021 13:52:27 +0200
parents 11714:d783716103c1
children 11716:30f1e826cc95
files plugins/mod_pubsub/mod_pubsub.lua plugins/mod_pubsub/pubsub.lib.lua
diffstat 2 files changed, 9 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/mod_pubsub/mod_pubsub.lua	Wed May 01 22:33:22 2019 +0200
+++ b/plugins/mod_pubsub/mod_pubsub.lua	Sun Jul 25 13:52:27 2021 +0200
@@ -199,6 +199,7 @@
 	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;
--- a/plugins/mod_pubsub/pubsub.lib.lua	Wed May 01 22:33:22 2019 +0200
+++ b/plugins/mod_pubsub/pubsub.lib.lua	Sun Jul 25 13:52:27 2021 +0200
@@ -328,9 +328,16 @@
 		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 })