Fix mod_muc_moderation regression:

See https://issues.prosody.im/1862
This commit is contained in:
John Livingston 2024-07-26 18:07:47 +02:00
parent ebc8fc8797
commit 6e92882176
No known key found for this signature in database
GPG Key ID: B17B5640CE66CDBC

View File

@ -83,11 +83,17 @@ local function moderate(actor, room_jid, stanza_id, retract, reason)
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 @@ local function moderate(actor, room_jid, stanza_id, retract, reason)
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);