Software /
code /
prosody-modules
Comparison
mod_muc_moderation/mod_muc_moderation.lua @ 5676:62c6e17a5e9d
Merge
author | Stephen Paul Weber <singpolyma@singpolyma.net> |
---|---|
date | Mon, 18 Sep 2023 08:24:19 -0500 |
parent | 5619:2e30af180da5 |
comparison
equal
deleted
inserted
replaced
5675:eade7ff9f52c | 5676:62c6e17a5e9d |
---|---|
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 | |
104 local actor_occupant = room:get_occupant_by_real_jid(actor) or room:new_occupant(jid.bare(actor), actor_nick); | |
105 if room.get_occupant_id then | |
106 -- This isn't a regular broadcast message going through the events occupant_id.lib hooks so we do this here | |
107 announcement:add_direct_child(st.stanza("occupant-id", { xmlns = xmlns_occupant_id; id = room:get_occupant_id(actor_occupant) })) | |
108 end | |
109 | |
98 if muc_log_archive.set and retract then | 110 if muc_log_archive.set and retract then |
99 local tombstone = st.message({ from = original.attr.from, type = "groupchat", id = original.attr.id }) | 111 local tombstone = st.message({ from = original.attr.from, type = "groupchat", id = original.attr.id }) |
100 :tag("moderated", { xmlns = xmlns_moderate, by = actor_nick }) | 112 :tag("moderated", { xmlns = xmlns_moderate, by = actor_nick }) |
101 :tag("retracted", { xmlns = xmlns_retract, stamp = dt.datetime() }):up(); | 113 :tag("retracted", { xmlns = xmlns_retract, stamp = dt.datetime() }):up(); |
114 | |
115 if room.get_occupant_id then | |
116 tombstone:add_direct_child(st.stanza("occupant-id", { xmlns = xmlns_occupant_id; id = room:get_occupant_id(actor_occupant) })) | |
117 | |
118 if moderated_occupant_id then | |
119 -- Copy occupant id from moderated message | |
120 tombstone:add_child(moderated_occupant_id); | |
121 end | |
122 end | |
102 | 123 |
103 if reason then | 124 if reason then |
104 tombstone:text_tag("reason", reason); | 125 tombstone:text_tag("reason", reason); |
105 end | 126 end |
106 tombstone:reset(); | 127 tombstone:reset(); |