XEP-xxxx: MUC Slow Mode

Abstract
This specification describes a way to rate limit messages a single user can send to a MUC room. It includes room configuration option, and how servers and clients can handle such a feature.
Author
John Livingston
Copyright
© 2024 – 2024 XMPP Standards Foundation. SEE LEGAL NOTICES.
Status

ProtoXEP

WARNING: This document has not yet been accepted for consideration or approved in any official manner by the XMPP Standards Foundation, and this document is not yet an XMPP Extension Protocol (XEP). If this document is accepted as a XEP by the XMPP Council, it will be published at <https://xmpp.org/extensions/> and announced on the <standards@xmpp.org> mailing list.
Type
Standards Track
Version
0.0.1 (2024-02-28)
Document Lifecycle
  1. Experimental
  2. Proposed
  3. Stable
  4. Final

1. Introduction

There are some contexts in which you want to be able to rate limit Multi-User Chat (XEP-0045) [1] messages. This could have multiple motivations: avoid flooding, garantee a better readability of the room when there are hundreds of active users, …

This specification propose a new option to MUC rooms, allowing room owners to fix a duration that users MUST wait between two messages. We will also specify how the server MUST reject messages send too quickly, and how clients SHOULD handle this feature (by preventing users to send messages without waiting the delay to be over, and displaying some information to them).

2. Requirements

This document addresses the following requirements:

3. Glossary

Clients
The client software used by end-users to join MUC rooms.
Moderator
A room role that is usually associated with room admins but that can be granted to non-admins.
MUC
The multi-user chat protocol for text-based conferencing (e.g. Multi-User Chat (XEP-0045) [1]).
Participant
An occupant who does not have admin status; in a moderated room, a participant is further defined as having voice (in contrast to a visitor). A participant has a role of "participant".
Role
A temporary position or privilege level within a room, distinct from a user's long-lived affiliation with the room; the possible roles are "moderator", "participant", and "visitor" (it is also possible to have no defined role). A role lasts only for the duration of an occupant's visit to a room. See Multi-User Chat (XEP-0045) [1].
Room administrator
A user empowered by the room owner to perform administrative functions such as banning users; however, a room administrator is not allowed to change the room configuration or to destroy the room. An admin has an affiliation of "admin". See Multi-User Chat (XEP-0045) [1].
Room owner
Users that have special access to a room, and that can edit room configuration. See Multi-User Chat (XEP-0045) [1] - Owner Use Cases.
Service Discovery Extensions
See Service Discovery Extensions (XEP-0128) [2]
Slow Mode
Feature allowing to rate limit user messages in a MUC room.
Slow Mode duration
When the Slow Mode feature is active, specifies the duration, in seconds, users must wait between two text messages.
Visitor
In a moderated room, an occupant who does not have voice (in contrast to a participant). A visitor has a role of "visitor".

4. Use Cases

The MUC Slow Mode can for example be used when a MUC room is associated to a live video stream. In such case, there are often hundreds of people writing at the same time. To avoid flooding, and encourage participants to post relevant messages, slow mode can be usefull.

5. MUC configuration

5.1 Activating Slow Mode in the MUC Room configuration

Your implementation MAY allow the Slow Mode feature to be set room by room, by their owners.

If room owners can configure the Slow Mode feature, the server MUST add a 'muc#roomconfig_slow_mode_duration' field in the room configuration form.

This field MUST have its type equal to 'text-single'.

This field SHOULD use Data Forms Validation , having its datatype equal to 'xs:integer'.

The 'value' of the field MUST be a positive integer, so you MUST add a 'range' validation, as described in Data Forms Validation (XEP-0122) [3].

Value '0' means that the slow mode is disabled for this room.

Any positive value is the duration, in seconds, users must wait between two messages.

Here is an example of response the server could send when a client is querying room configuration form:

Example 1. Room configuration example
<iq from='coven@chat.shakespeare.lit'
  id='config1'
  to='crone1@shakespeare.lit/desktop'
  type='result'>
  <query xmlns='http://jabber.org/protocol/muc#owner'>
    <x xmlns='jabber:x:data' type='form'>
      <title>Configuration for "coven" Room</title>
      <instructions>
        Complete this form to modify the
        configuration of your room.
      </instructions>
      <field
          type='hidden'
          var='FORM_TYPE'>
        <value>http://jabber.org/protocol/muc#roomconfig</value>
      </field>
      <field
        var='muc#roomconfig_slow_mode_duration'
        type='text-single'
        label='Slow Mode (0=disabled, any positive integer= users can send a message every X seconds.)'
      >
        <validate xmlns='http://jabber.org/protocol/xdata-validate' datatype='xs:integer'>
          <range min='0'/>
        </validate>
        <value>20</value>
      </field>
      <!-- and any other field... -->
    </x>
  </query>
</iq>

If the configuration is changed, the server SHOULD send a status code '104', as specified in XEP-0045 - Notification of configuration changes .

5.2 Client discovering

The feature can be enabled on a room:

In other words: you can enable this feature, without adding the field in the room configuration form. This allows for example server admins to apply a rate limit server-wide, or to set the slow mode programmatically on any wanted criteria (number of users in the room, current server load, room context, ...).

In any case, to allow clients to discover that the feature is active, the server MUST respond on room information queries by adding a 'muc#roominfo_slow_mode_duration' field. This field type MUST be 'text-single', and its value MUST be a positive integer.

Value '0' means that the slow mode is disabled for this room.

Any positive value is the duration, in seconds, users must wait between two messages.

Any invalid (non-positive integer) value sent by the server MUST be considered as equal to '0' (in case of a bad implementation).

Here is an example of response the server could send when a client is querying room information:

Example 2. Room information example
<iq from='coven@chat.shakespeare.lit'
    id='ik3vs715'
    to='hag66@shakespeare.lit/pda'
    type='result'>
  <query xmlns='http://jabber.org/protocol/disco#info'>
    <identity
        category='conference'
        name='The place to be'
        type='text'/>
    <feature var='http://jabber.org/protocol/muc'/>
    <x xmlns='jabber:x:data' type='result'>
      <field var='FORM_TYPE' type='hidden'>
        <value>http://jabber.org/protocol/muc#roominfo</value>
      </field>
      <field var='muc#roominfo_slow_mode_duration' type='text-single'>
        <value>20</value>
      </field>

      <!-- and any other field... -->
    </x>
  </query>
</iq>

If the slow mode duration has changed (either because the room configuration was modified, or because a server parameter has changed, or any other reason), the server SHOULD send a status code '104', as specified in XEP-0045 - Notification of configuration changes.

6. Server-side rate limiting

When the Slow Mode is enabled, server MUST NOT accept two consecutive messages from the same user, to the same room, until the slow mode duration has elapsed.

Only messages containing at least one '<body/>' element must be taking into account (to avoid counting 'chatstate' messages for example).

Room administrators and owners MUST NOT be rate limited.

If a user bypass the limit, the server MUST reply an error stanza, that respects RFC 6120 [4] stanza erors (see RFC6120 - stanza errors), to reject the message. Especially:

Here is an example or error stanza:

Example 3. Example error stanza
<message
  xmlns="jabber:client"
  type="error"
  to="crone1@shakespeare.lit/desktop"
  id="528df978-aa6b-422a-b987-056a810c4733"
  from="coven@chat.shakespeare.lit"
>
  <error type="wait">
    <policy-violation xmlns="urn:ietf:params:xml:ns:xmpp-stanzas" />
    <text xmlns="urn:ietf:params:xml:ns:xmpp-stanzas">
      You have exceeded the limit imposed by the slow mode in this room.
      You have to wait 20 seconds between messages. Please try again later.
    </text>
  </error>
</message>

The rejected message MUST NOT be forwarded to other room occupants.

7. Client handling

When a participant joins a room, the client SHOULD request room information as described in section Client discovering", and look for the 'muc#roominfo_slow_mode_duration' field.

If this field is present, and contains a valid strictly positive integer value, the client SHOULD display an information somewhere, to tell users that there is a slow mode limitation that applies to this room. This information MAY also be displayed to users for which the rate limit does not apply (administrators, owners, ...).

Moreover, each time a participant sends a text message, the client SHOULD prevent the user to send another message before the timeout is passed. This MAY be done either by disabling the input field, or the submit button. If the user has at least the administrator acces level, the client SHOULD NOT disable the input field or the submit button.

To avoid some frustrating behaviour, in case there is some lag on the server for example, the client MAY start counting time after receiving the message echo. Indeed, if the first message is processed with some delay by the server, it could consider that the duration is not passed yet when receiving the next one.

8. Security Considerations

As a same user can join a room with multiple sessions and/or nicknames, the server MUST use the appropriate criteria to identify the account, and apply the same limits to all user's sessions.

The slow mode duration parameter is a positive integer. When parsing its value, clients and servers MUST ignore invalid value. They MUST also check that this value is not to big to store in memory (this depends on the data type used by the implementation).

9. IANA Considerations

This document requires no interaction with the Internet Assigned Numbers Authority (IANA).

10. XMPP Registrar Considerations

10.1 Field Standardization

Field Standardization for Data Forms (XEP-0068) [5] defines a process for standardizing the fields used within Data Forms scoped by a particular namespace, and the XMPP Registrar maintains a registry of such FORM_TYPES (see <https://xmpp.org/registrar/formtypes.html>). In this XEP there are two uses of such form fields:

  1. Configuration of the slow mode duration using the 'muc#roomconfig_slow_mode_duration' field.
  2. Discovery of the slow mode duration using the 'muc#roominfo_slow_mode_duration' field.

The registry submissions associated with these namespaces are defined below.

10.1.1 muc#roomconfig_slow_mode_duration

The registrar shall add the following field to the 'muc#roomconfig' data form:

Example 4. Registry Submission
<form_type>
  <name>http://jabber.org/protocol/muc#roomconfig</name>
  <doc>XEP-XXXX</doc>
  <desc>
    Forms extension for slow mode support in a MUC room.
  </desc>
  <field
    var='muc#roomconfig_slow_mode_duration'
    type='text-single'
    label='Slow Mode (0=disabled, any positive integer= users can send a message every X seconds.)'
  />  
</form_type>

10.1.2 muc#roominfo_slow_mode_duration

The registrar shall add the following field to the 'muc#roominfo' data form:

Example 5. Registry Submission
<form_type>
  <name>http://jabber.org/protocol/muc#roominfo</name>
  <doc>XEP-XXXX</doc>
  <desc>
    Forms extension for slow mode support in a MUC room.
  </desc>
  <field
    var='muc#roominfo_slow_mode_duration'
    label='Slow Mode (0=disabled, any positive integer= users can send a message every X seconds.)'
  />  
</form_type>
  

Appendices

Appendix A: Document Information

Series
XEP
Number
xxxx
Publisher
XMPP Standards Foundation
Status
ProtoXEP
Type
Standards Track
Version
0.0.1
Last Updated
2024-02-28
Approving Body
XMPP Council
Dependencies
XMPP Core, XEP-0001, XEP-0045, XEP-0068, XEP-0122, XEP-0128, RFC6120
Supersedes
None
Superseded By
None
Short Name
NOT_YET_ASSIGNED

This document in other formats: XML  PDF

Appendix B: Author Information

John Livingston
Email
contact@john-livingston.fr
JabberID
john@im.yiny.org

Copyright

This XMPP Extension Protocol is copyright © 1999 – 2024 by the XMPP Standards Foundation (XSF).

Permissions

Permission is hereby granted, free of charge, to any person obtaining a copy of this specification (the "Specification"), to make use of the Specification without restriction, including without limitation the rights to implement the Specification in a software program, deploy the Specification in a network service, and copy, modify, merge, publish, translate, distribute, sublicense, or sell copies of the Specification, and to permit persons to whom the Specification is furnished to do so, subject to the condition that the foregoing copyright notice and this permission notice shall be included in all copies or substantial portions of the Specification. Unless separate permission is granted, modified works that are redistributed shall not contain misleading information regarding the authors, title, number, or publisher of the Specification, and shall not claim endorsement of the modified works by the authors, any organization or project to which the authors belong, or the XMPP Standards Foundation.

Disclaimer of Warranty

## NOTE WELL: This Specification is provided on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. ##

Limitation of Liability

In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall the XMPP Standards Foundation or any author of this Specification be liable for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising from, out of, or in connection with the Specification or the implementation, deployment, or other use of the Specification (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if the XMPP Standards Foundation or such author has been advised of the possibility of such damages.

IPR Conformance

This XMPP Extension Protocol has been contributed in full conformance with the XSF's Intellectual Property Rights Policy (a copy of which can be found at <https://xmpp.org/about/xsf/ipr-policy> or obtained by writing to XMPP Standards Foundation, P.O. Box 787, Parker, CO 80134 USA).

Visual Presentation

The HTML representation (you are looking at) is maintained by the XSF. It is based on the YAML CSS Framework, which is licensed under the terms of the CC-BY-SA 2.0 license.

Appendix D: Relation to XMPP

The Extensible Messaging and Presence Protocol (XMPP) is defined in the XMPP Core (RFC 6120) and XMPP IM (RFC 6121) specifications contributed by the XMPP Standards Foundation to the Internet Standards Process, which is managed by the Internet Engineering Task Force in accordance with RFC 2026. Any protocol defined in this document has been developed outside the Internet Standards Process and is to be understood as an extension to XMPP rather than as an evolution, development, or modification of XMPP itself.

Appendix E: Discussion Venue

The primary venue for discussion of XMPP Extension Protocols is the <standards@xmpp.org> discussion list.

Discussion on other xmpp.org discussion lists might also be appropriate; see <https://xmpp.org/community/> for a complete list.

Given that this XMPP Extension Protocol normatively references IETF technologies, discussion on the <xsf-ietf@xmpp.org> list might also be appropriate.

Errata can be sent to <editor@xmpp.org>.

Appendix F: Requirements Conformance

The following requirements keywords as used in this document are to be interpreted as described in RFC 2119: "MUST", "SHALL", "REQUIRED"; "MUST NOT", "SHALL NOT"; "SHOULD", "RECOMMENDED"; "SHOULD NOT", "NOT RECOMMENDED"; "MAY", "OPTIONAL".

Appendix G: Notes

1. XEP-0045: Multi-User Chat <https://xmpp.org/extensions/xep-0045.html>.

2. XEP-0128: Service Discovery Extensions <https://xmpp.org/extensions/xep-0128.html>.

3. XEP-0122: Data Forms Validation <https://xmpp.org/extensions/xep-0122.html>.

4. RFC 6120: Extensible Messaging and Presence Protocol (XMPP): Core <http://tools.ietf.org/html/rfc6120>.

5. XEP-0068: Field Data Standardization for Data Forms <https://xmpp.org/extensions/xep-0068.html>.

Appendix H: Revision History

Note: Older versions of this specification might be available at https://xmpp.org/extensions/attic/

  1. Version 0.0.1 (2024-02-28)

    First draft.

    psa

Appendix I: Bib(La)TeX Entry

@report{livingston2024xepxxxx,
  title = {MUC Slow Mode},
  author = {Livingston, John},
  type = {XEP},
  number = {xxxx},
  version = {0.0.1},
  institution = {XMPP Standards Foundation},
  url = {https://xmpp.org/extensions/xep-xxxx.html},
  date = {2024-02-28/2024-02-28},
}

END