Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update mod_muc_room to support XEP-0425 0.3.0 #4193

Open
badlop opened this issue Apr 5, 2024 · 2 comments
Open

Update mod_muc_room to support XEP-0425 0.3.0 #4193

badlop opened this issue Apr 5, 2024 · 2 comments

Comments

@badlop
Copy link
Member

badlop commented Apr 5, 2024

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

-protocol({xep, 425, '0.2.1', '23.04', "", ""}).

There's a new version of XEP-0425, 0.3.0: xsf/xeps@ef79d2c

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='room1@conference.localhost' 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:

  <xs:element name='retract'>
    <xs:attribute name='id' type='xs:string' use='required'/>
  </xs:element>
  • but later, in XEP-0425 example, when a retract element is used, it doesn't include id:
<retract xmlns='urn:xmpp:message-retract:1'/>
  • Instead, the id is provided in the new moderate element:
<moderate id="stanza-id-1" xmlns='urn:xmpp:message-moderate:1'>
@badlop badlop changed the title Missing support in mod_muc_room to handle Moderated Message Retraction Update mod_muc_room to support XEP-0425 0.3.0 (VERY EARLY DRAFT) Apr 5, 2024
@edhelas
Copy link

edhelas commented May 18, 2024

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).

@badlop badlop self-assigned this May 28, 2024
@badlop badlop added this to the ejabberd 24.xx milestone May 28, 2024
@badlop badlop changed the title Update mod_muc_room to support XEP-0425 0.3.0 (VERY EARLY DRAFT) Update mod_muc_room to support XEP-0425 0.3.0 May 28, 2024
@badlop
Copy link
Member Author

badlop commented May 28, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants