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 (VERY EARLY DRAFT) #4193

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

Update mod_muc_room to support XEP-0425 0.3.0 (VERY EARLY DRAFT) #4193

badlop opened this issue Apr 5, 2024 · 0 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant