ejabberd
ejabberd copied to clipboard
Update mod_muc_room to support XEP-0425 0.3.0
ejabberd allows a MUC occupant to retract a message he has sent, using XEP-0424: Message Retraction.
It is also possible for a room moderator to retract a message sent by another occupant, using XEP-0425: Moderated Message Retraction.
Right now ejabberd implements XEP-0425 0.2.1, as documented in https://github.com/processone/ejabberd/blob/426e33d3a67302518adb9b778dca448ff71166c9/src/mod_mam.erl#L31
There's a new version of XEP-0425, 0.3.0: https://github.com/xsf/xeps/commit/ef79d2cad2b0a47dc08d7e7ab685446ae263f53f
Here is a very dirty early and unfinished patch to support that XEP version:
diff --git a/src/mod_muc_room.erl b/src/mod_muc_room.erl
index 72ec867be..88528ed76 100644
--- a/src/mod_muc_room.erl
+++ b/src/mod_muc_room.erl
@@ -503,6 +503,10 @@ normal_state({route, <<"">>,
process_iq_adhoc(From, IQ, StateData);
#register{} ->
mod_muc:process_iq_register(IQ);
+ #message_moderate{} ->
+ Id = (SubEl#message_moderate.retract)#message_retract.id,
+ ApplyTo = #fasten_apply_to{id = Id},
+ process_iq_moderate(From, IQ, ApplyTo, SubEl, StateData);
#fasten_apply_to{} = ApplyTo ->
case xmpp:get_subtag(ApplyTo, #message_moderate{}) of
#message_moderate{} = Moderate ->
After applying this patch, a room moderator can send to the room:
<iq type='set' to='[email protected]' id='retract-request-1'>
<moderate xmlns='urn:xmpp:message-moderate:0'>
<retract id="1712326927080870" xmlns='urn:xmpp:message-retract:1'/>
<reason>This message contains inappropriate content for this forum</reason>
</moderate>
</iq>
Interestingly, there seems to be a bug in XEP-0425 itself:
- XEP-0424 schema says:
<xs:element name='retract'>
<xs:attribute name='id' type='xs:string' use='required'/>
</xs:element>
- but later, in XEP-0425 example, when a
retractelement is used, it doesn't includeid:
<retract xmlns='urn:xmpp:message-retract:1'/>
- Instead, the id is provided in the new
moderateelement:
<moderate id="stanza-id-1" xmlns='urn:xmpp:message-moderate:1'>
I am ready to bump my Movim implementation of XEP-0425 to 0.3.0 (https://xmpp.org/extensions/xep-0425.html#revision-history-v0.3.0).
Be careful the urn:xmpp:message-moderate:0 namespace was also bumped to urn:xmpp:message-moderate:1.
This update will allow me to also drop the support of Message Fastening for XEP-0424: Message Retraction (https://xmpp.org/extensions/xep-0424.html#revision-history-v0.4.0).
I've updated the xmpp library and ejabberd to support 0.3.0, while still keeping support for 0.2.1.
Message retraction works for me using 0.3.0, at least I tried manually. Can you please try it yourself too and report if it's correct or requires some more change?
You can compile ejabberd master branch, or download binary installers or use a container.