comparison mod_muc_moderation/mod_muc_moderation.lua @ 5611:06fad22672e1

mod_muc_moderation: Copy XEP-0421 occupant-id from retracted message Lets clients correlate the sender of whatever was retracted by moderators. Behavior limited to Prosody 0.12, otherwise there are no assurances of the origin of the occupant-id tag. Ref #1816
author Kim Alvefur <zash@zash.se>
date Thu, 20 Jul 2023 10:37:27 +0200
parents 4d6af8950016
children 2e30af180da5
comparison
equal deleted inserted replaced
5610:67f7df9892bb 5611:06fad22672e1
25 end 25 end
26 26
27 -- Namespaces 27 -- Namespaces
28 local xmlns_fasten = "urn:xmpp:fasten:0"; 28 local xmlns_fasten = "urn:xmpp:fasten:0";
29 local xmlns_moderate = "urn:xmpp:message-moderate:0"; 29 local xmlns_moderate = "urn:xmpp:message-moderate:0";
30 local xmlns_occupant_id = "urn:xmpp:occupant-id:0";
30 local xmlns_retract = "urn:xmpp:message-retract:0"; 31 local xmlns_retract = "urn:xmpp:message-retract:0";
31 32
32 -- Discovering support 33 -- Discovering support
33 module:hook("muc-disco#info", function (event) 34 module:hook("muc-disco#info", function (event)
34 event.reply:tag("feature", { var = xmlns_moderate }):up(); 35 event.reply:tag("feature", { var = xmlns_moderate }):up();
93 94
94 if reason then 95 if reason then
95 announcement:text_tag("reason", reason); 96 announcement:text_tag("reason", reason);
96 end 97 end
97 98
99 local moderated_occupant_id = original:get_child("occupant-id", xmlns_occupant_id);
100 if room.get_occupant_id and moderated_occupant_id then
101 announcement:add_direct_child(moderated_occupant_id);
102 end
103
98 if muc_log_archive.set and retract then 104 if muc_log_archive.set and retract then
99 local tombstone = st.message({ from = original.attr.from, type = "groupchat", id = original.attr.id }) 105 local tombstone = st.message({ from = original.attr.from, type = "groupchat", id = original.attr.id })
100 :tag("moderated", { xmlns = xmlns_moderate, by = actor_nick }) 106 :tag("moderated", { xmlns = xmlns_moderate, by = actor_nick })
101 :tag("retracted", { xmlns = xmlns_retract, stamp = dt.datetime() }):up(); 107 :tag("retracted", { xmlns = xmlns_retract, stamp = dt.datetime() }):up();
108
109 if room.get_occupant_id and moderated_occupant_id then
110 -- Copy occupant id from moderated message
111 tombstone:add_child(moderated_occupant_id);
112 end
102 113
103 if reason then 114 if reason then
104 tombstone:text_tag("reason", reason); 115 tombstone:text_tag("reason", reason);
105 end 116 end
106 tombstone:reset(); 117 tombstone:reset();