changeset 5942:5ccc03c33158

mod_muc_moderation: Fix a regression. Actor occupant-id was not added under the moderated tag, but at the top level.
author John Livingston <git@john-livingston.fr>
date Fri, 26 Jul 2024 18:22:30 +0200
parents d58e4c70feb2
children 5076b78c95ef
files mod_muc_moderation/mod_muc_moderation.lua
diffstat 1 files changed, 12 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/mod_muc_moderation/mod_muc_moderation.lua	Fri Jul 26 17:07:05 2024 +0200
+++ b/mod_muc_moderation/mod_muc_moderation.lua	Fri Jul 26 18:22:30 2024 +0200
@@ -83,11 +83,17 @@
 		end
 	end
 
+	local actor_occupant = room:get_occupant_by_real_jid(actor) or room:new_occupant(jid.bare(actor), actor_nick);
 
 	local announcement = st.message({ from = room_jid, type = "groupchat", id = id.medium(), })
 		:tag("apply-to", { xmlns = xmlns_fasten, id = stanza_id })
 			:tag("moderated", { xmlns = xmlns_moderate, by = 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_child(st.stanza("occupant-id", { xmlns = xmlns_occupant_id; id = room:get_occupant_id(actor_occupant) }));
+	end
+
 	if retract then
 		announcement:tag("retract", { xmlns = xmlns_retract }):up();
 	end
@@ -101,20 +107,18 @@
 		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();
+				:tag("retracted", { xmlns = xmlns_retract, stamp = dt.datetime() });
 
 		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) }))
+			tombstone:add_child(st.stanza("occupant-id", { xmlns = xmlns_occupant_id; id = room:get_occupant_id(actor_occupant) }));
+		end
 
+		tombstone:up();
+
+		if room.get_occupant_id then
 			if moderated_occupant_id then
 				-- Copy occupant id from moderated message
 				tombstone:add_child(moderated_occupant_id);