changeset 5943:5076b78c95ef

mod_muc_moderation: Fix occupant-id placement in moderated tombstone.
author John Livingston <git@john-livingston.fr>
date Mon, 29 Jul 2024 12:35:19 +0200 (4 months ago)
parents 5ccc03c33158
children 4b677e445b8a
files mod_muc_moderation/mod_muc_moderation.lua
diffstat 1 files changed, 14 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/mod_muc_moderation/mod_muc_moderation.lua	Fri Jul 26 18:22:30 2024 +0200
+++ b/mod_muc_moderation/mod_muc_moderation.lua	Mon Jul 29 12:35:19 2024 +0200
@@ -107,27 +107,27 @@
 		announcement:add_direct_child(moderated_occupant_id);
 	end
 
+	announcement:reset();
+
 	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() });
-
-		if room.get_occupant_id then
-			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);
-			end
-		end
+				:tag("retracted", { xmlns = xmlns_retract, stamp = dt.datetime() }):up();
 
 		if reason then
 			tombstone:text_tag("reason", reason);
 		end
+
+		if room.get_occupant_id then
+			if actor_occupant then
+				tombstone:add_child(st.stanza("occupant-id", { xmlns = xmlns_occupant_id; id = room:get_occupant_id(actor_occupant) }));
+			end
+
+			if moderated_occupant_id then
+				-- Copy occupant id from moderated message
+				tombstone:add_direct_child(moderated_occupant_id);
+			end
+		end
 		tombstone:reset();
 
 		local was_replaced = muc_log_archive:set(room_node, stanza_id, tombstone);