Software /
code /
prosody-modules
Changeset
4814:5f12c75fd210
mod_muc_moderation: Handle non-retraction moderation
The XEP is light on details and does not show any example of
non-retraction uses.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Tue, 07 Dec 2021 20:36:13 +0100 |
parents | 4813:0a257d1402c3 |
children | 4815:9c2af2146ee2 |
files | mod_muc_moderation/mod_muc_moderation.lua |
diffstat | 1 files changed, 14 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- 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"));