# HG changeset patch # User Kim Alvefur # Date 1638905773 -3600 # Node ID 5f12c75fd210685d228e43cbf907a6f99f2ad3f0 # Parent 0a257d1402c36a1099797d6c5796fba48cb78971 mod_muc_moderation: Handle non-retraction moderation The XEP is light on details and does not show any example of non-retraction uses. diff -r 0a257d1402c3 -r 5f12c75fd210 mod_muc_moderation/mod_muc_moderation.lua --- a/mod_muc_moderation/mod_muc_moderation.lua Mon Dec 06 18:19:19 2021 +0100 +++ b/mod_muc_moderation/mod_muc_moderation.lua Tue Dec 07 20:36:13 2021 +0100 @@ -44,6 +44,7 @@ if not moderate_tag then return end -- some other kind of fastening? local reason = moderate_tag:get_child_text("reason"); + local retract = moderate_tag:get_child("retract", xmlns_retract); local room_jid = stanza.attr.to; local room_node = jid.split(room_jid); @@ -92,23 +93,28 @@ return true; end - -- Replacements - 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(); 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 }) - :tag("retract", { xmlns = xmlns_retract }):up(); + + if retract then + announcement:tag("retract", { xmlns = xmlns_retract }):up(); + end if reason then - tombstone:text_tag("reason", reason); announcement:text_tag("reason", reason); end - if muc_log_archive.set then - -- Tombstone + 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(); + + if reason then + tombstone:text_tag("reason", reason); + end + local was_replaced = muc_log_archive:set(room_node, stanza_id, tombstone); if not was_replaced then origin.send(st.error_reply(stanza, "wait", "internal-server-error"));