Changeset

5619:2e30af180da5

mod_muc_moderation: Stamp XEP-0421 occupant-id for the acting moderator Gives clients some hint about which moderator it was who did the deed. The @by attribute does have the nick of the actor, but they could change their nickname at some point, which is what occupant-id solves. Ref #1816
author Kim Alvefur <zash@zash.se>
date Thu, 20 Jul 2023 10:38:33 +0200
parents 5618:06fad22672e1
children 5620:a9682cad0e67
files mod_muc_moderation/mod_muc_moderation.lua
diffstat 1 files changed, 13 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/mod_muc_moderation/mod_muc_moderation.lua	Thu Jul 20 10:37:27 2023 +0200
+++ b/mod_muc_moderation/mod_muc_moderation.lua	Thu Jul 20 10:38:33 2023 +0200
@@ -101,14 +101,24 @@
 		announcement:add_direct_child(moderated_occupant_id);
 	end
 
+	local actor_occupant = room:get_occupant_by_real_jid(actor) or room:new_occupant(jid.bare(actor), actor_nick);
+	if room.get_occupant_id then
+		-- This isn't a regular broadcast message going through the events occupant_id.lib hooks so we do this here
+		announcement:add_direct_child(st.stanza("occupant-id", { xmlns = xmlns_occupant_id; id = room:get_occupant_id(actor_occupant) }))
+	end
+
 	if muc_log_archive.set and retract then
 		local tombstone = st.message({ from = original.attr.from, type = "groupchat", id = original.attr.id })
 			:tag("moderated", { xmlns = xmlns_moderate, by = actor_nick })
 				:tag("retracted", { xmlns = xmlns_retract, stamp = dt.datetime() }):up();
 
-		if room.get_occupant_id and moderated_occupant_id then
-			-- Copy occupant id from moderated message
-			tombstone:add_child(moderated_occupant_id);
+		if room.get_occupant_id then
+			tombstone:add_direct_child(st.stanza("occupant-id", { xmlns = xmlns_occupant_id; id = room:get_occupant_id(actor_occupant) }))
+
+			if moderated_occupant_id then
+				-- Copy occupant id from moderated message
+				tombstone:add_child(moderated_occupant_id);
+			end
 		end
 
 		if reason then