Mercurial > prosody-modules
comparison mod_muc_anonymize_moderation_actions/mod_muc_anonymize_moderation_actions.lua @ 5945:a316fee71bed
mod_muc_anonymize_moderation_actions: anonymize muc moderation announcements and tombstones.
author | John Livingston <git@john-livingston.fr> |
---|---|
date | Mon, 29 Jul 2024 13:11:43 +0200 |
parents | d58e4c70feb2 |
children | bfb8d7b53954 |
comparison
equal
deleted
inserted
replaced
5944:4b677e445b8a | 5945:a316fee71bed |
---|---|
37 if (event.room and get_anonymize_moderation_actions(event.room)) then | 37 if (event.room and get_anonymize_moderation_actions(event.room)) then |
38 event.actor = nil; | 38 event.actor = nil; |
39 end | 39 end |
40 end | 40 end |
41 | 41 |
42 local function remove_moderate_actor(event) | |
43 local room, announcement, tombstone = event.room, event.announcement, event.tombstone; | |
44 if not get_anonymize_moderation_actions(room) then | |
45 return; | |
46 end | |
47 | |
48 local moderated = announcement:find("{urn:xmpp:fasten:0}apply-to/{urn:xmpp:message-moderate:0}moderated"); | |
49 if moderated then | |
50 module:log("debug", "We must anonymize the moderation announcement for stanza %s", event.stanza_id); | |
51 moderated.attr.by = nil; | |
52 moderated:remove_children("occupant-id", "urn:xmpp:occupant-id:0"); | |
53 end | |
54 | |
55 if tombstone then | |
56 local moderated = tombstone:get_child("moderated", "urn:xmpp:message-moderate:0"); | |
57 if moderated then | |
58 module:log("debug", "We must anonymize the moderation tombstone for stanza %s", event.stanza_id); | |
59 moderated.attr.by = nil; | |
60 moderated:remove_children("occupant-id", "urn:xmpp:occupant-id:0"); | |
61 end | |
62 end | |
63 end | |
64 | |
42 module:hook("muc-config-submitted/muc#roomconfig_anonymize_moderation_actions", config_submitted); | 65 module:hook("muc-config-submitted/muc#roomconfig_anonymize_moderation_actions", config_submitted); |
43 module:hook("muc-config-form", add_form_option, form_position); | 66 module:hook("muc-config-form", add_form_option, form_position); |
44 module:hook("muc-broadcast-presence", remove_actor); | 67 module:hook("muc-broadcast-presence", remove_actor); |
68 module:hook("muc-moderate-message", remove_moderate_actor); |