# HG changeset patch # User John Livingston # Date 1722251503 -7200 # Node ID a316fee71bed1086728b2b98f32dc2b7bf278eef # Parent 4b677e445b8a7ba4385127427b635e04359faa33 mod_muc_anonymize_moderation_actions: anonymize muc moderation announcements and tombstones. diff -r 4b677e445b8a -r a316fee71bed mod_muc_anonymize_moderation_actions/mod_muc_anonymize_moderation_actions.lua --- a/mod_muc_anonymize_moderation_actions/mod_muc_anonymize_moderation_actions.lua Mon Jul 29 13:08:43 2024 +0200 +++ b/mod_muc_anonymize_moderation_actions/mod_muc_anonymize_moderation_actions.lua Mon Jul 29 13:11:43 2024 +0200 @@ -39,6 +39,30 @@ end end +local function remove_moderate_actor(event) + local room, announcement, tombstone = event.room, event.announcement, event.tombstone; + if not get_anonymize_moderation_actions(room) then + return; + end + + local moderated = announcement:find("{urn:xmpp:fasten:0}apply-to/{urn:xmpp:message-moderate:0}moderated"); + if moderated then + module:log("debug", "We must anonymize the moderation announcement for stanza %s", event.stanza_id); + moderated.attr.by = nil; + moderated:remove_children("occupant-id", "urn:xmpp:occupant-id:0"); + end + + if tombstone then + local moderated = tombstone:get_child("moderated", "urn:xmpp:message-moderate:0"); + if moderated then + module:log("debug", "We must anonymize the moderation tombstone for stanza %s", event.stanza_id); + moderated.attr.by = nil; + moderated:remove_children("occupant-id", "urn:xmpp:occupant-id:0"); + end + end +end + module:hook("muc-config-submitted/muc#roomconfig_anonymize_moderation_actions", config_submitted); module:hook("muc-config-form", add_form_option, form_position); module:hook("muc-broadcast-presence", remove_actor); +module:hook("muc-moderate-message", remove_moderate_actor);