# HG changeset patch # User John Livingston # Date 1722251323 -7200 # Node ID 4b677e445b8a7ba4385127427b635e04359faa33 # Parent 5076b78c95ef07f2cbda1c762a62733be29478e4 mod_muc_moderation: adding a new hook that can be used to cancel the moderation, or modify resulting stanzas. diff -r 5076b78c95ef -r 4b677e445b8a mod_muc_moderation/mod_muc_moderation.lua --- a/mod_muc_moderation/mod_muc_moderation.lua Mon Jul 29 12:35:19 2024 +0200 +++ b/mod_muc_moderation/mod_muc_moderation.lua Mon Jul 29 13:08:43 2024 +0200 @@ -109,8 +109,9 @@ announcement:reset(); + local tombstone = nil; if muc_log_archive.set and retract then - local tombstone = st.message({ from = original.attr.from, type = "groupchat", id = original.attr.id }) + 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(); @@ -129,7 +130,25 @@ end end tombstone:reset(); + end + -- fire an event, that can be used to cancel the moderation, or modify stanzas. + local event = { + room = room; + announcement = announcement; + tombstone = tombstone; + stanza_id = stanza_id; + retract = retract; + reason = reason; + actor = actor; + actor_nick = actor_nick; + }; + if module:fire_event("muc-moderate-message", event) then + -- TODO: allow to change the error message? + return false, "wait", "internal-server-error"; + end + + if tombstone then local was_replaced = muc_log_archive:set(room_node, stanza_id, tombstone); if not was_replaced then return false, "wait", "internal-server-error";