Diff

plugins/mod_pep.lua @ 12960:31b22cc221b5

mod_pubsub, mod_pep: Support per-node configurable inclusion of publisher This matches ejabberd's behaviour, using the 'pubsub#itemreply' config option. Although the current definition of this option in the specification is not as clear as it could be, I think matching what existing deployments do is the best option to resolve the ambiguity and reduce fragmentation. We should update the spec to be clearer about how to use and interpret this option. The 'expose_publisher' option for mod_pubsub is now an override (always expose or never expose). If unset, it will use the per-node config (which defaults to not exposing). Thanks to Link Mauve, edhelas and goffi for sparking this feature.
author Matthew Wild <mwild1@gmail.com>
date Wed, 22 Mar 2023 11:39:19 +0000
parent 12260:e729c994e7c7
child 12962:1b179d14a1dd
line wrap: on
line diff
--- a/plugins/mod_pep.lua	Tue Mar 21 20:43:42 2023 +0100
+++ b/plugins/mod_pep.lua	Wed Mar 22 11:39:19 2023 +0000
@@ -136,10 +136,14 @@
 local function get_broadcaster(username)
 	local user_bare = jid_join(username, host);
 	local function simple_broadcast(kind, node, jids, item, _, node_obj)
+		local expose_publisher;
 		if node_obj then
 			if node_obj.config["notify_"..kind] == false then
 				return;
 			end
+			if node_obj.config.itemreply == "publisher" then
+				expose_publisher = true;
+			end
 		end
 		if kind == "retract" then
 			kind = "items"; -- XEP-0060 signals retraction in an <items> container
@@ -151,6 +155,9 @@
 				if node_obj and node_obj.config.include_payload == false then
 					item:maptags(function () return nil; end);
 				end
+				if not expose_publisher then
+					item.attr.publisher = nil;
+				end
 			end
 		end