XEP-0490: Message Displayed Synchronization

Abstract
This specification allows multiple clients of the same user to synchronize the displayed state of their chats.
Author
Daniel Gultsch
Copyright
© 2024 – 2024 XMPP Standards Foundation. SEE LEGAL NOTICES.
Status

Proposed

NOTICE: This document is currently within Last Call or under consideration by the XMPP Council for advancement to the next stage in the XSF standards process. The Last Call ends on 2024-10-31. Please send your feedback to the standards@xmpp.org discussion list.
Type
Standards Track
Version
0.1.0 (2024-03-26)
Document Lifecycle
  1. Experimental
  2. Proposed
  3. Stable
  4. Final

1. Introduction

In multi-device environments marking a chat as displayed on one device should mark that chat as displayed on all devices. Historically carbon copies (Message Carbons (XEP-0280) [1]) of the <displayed/> element of Displayed Markers (Displayed Markers (XEP-0333) [2]) have been used to achieve this effect. However this approach has a couple of downsides that this specification is trying eliminate:

This specification isolates the task of multi-device synchronization from providing information to the contact, while borrowing some of the semantics of Displayed Markers such as displayed refering to all messages up to this point.

2. Requirements

3. Glossary

Displayed
Colloquially this is also known as read. However since a common implementation of read is: "shown on screen, in full, in the context of the chat", and this gives no indication on whether the user has actually read a message, displayed was chosen as a more accurate terminology. A message might also be manually acknowledged by the user, for example via a mark as read action in a notification. Implementations are also possible, for example in smart home devices or infotainment systems, where the message is read aloud by a Text-to-Speech system, but never actually displayed. It is up to the implementors discretion to determine what the best approximation of the user has had a reasonable chance to mentally process the message is.

4. Use Cases

4.1 Server-side persistence

Clients use items in a private PEP (Personal Eventing Protocol (XEP-0163) [3]) node called 'urn:xmpp:mds:displayed:0' to synchronize and persist the displayed state (See Best Practices for Persistent Storage of Private Data via Publish-Subscribe (XEP-0223) [4]). The item ID corresponds to the JID of the respective chat. For normal, 1:1 chats this SHOULD be the bare JID of the contact, for group chats this SHOULD be the bare JID of the room and for private messages in group chats the full JID of the participant.

The item contains a single <displayed/> element qualified by the 'xrn:xmpp:mds:displayed:0' namespace. The <displayed/> element MUST contain exactly one Unique and Stable Stanza IDs (XEP-0359) [5] <stanza-id/> element that corresponds to the stanza-id of the most recent, displayed message, in that particular chat.

4.2 Flagging chat as displayed

Only messages received by the user (meaning sent by third parties such as a contact, a participant in a group chat, etc) SHOULD be flagged as 'displayed'. However since 'displayed' means all messages up to this point and the stanza-id of a message sent by the user indicates a valid point in the chat history, sent messages MAY be flagged as well.

Flagging a chat as displayed up to this point happens by publishing a PEP item with an id corresponding to the JID of the chat and a <displayed/> payload element into the 'urn:xmpp:mds:displayed:0' node.

For group chats the <stanza-id/> child of the <displayed/> element refers to the stanza-id injected by the room. For all other chats the stanza-id child refers to the stanza-id injected by the user’s server (the server hosting the user account).

The client MUST include appropriate publish-options in the publication, including, but not limited to, setting the access model to whitelist and the max-items to max.

Example 1. Client marks a chat as display
<iq from='juliet@capulet.lit/balcony' type='set' id='flag-as-displayed-1'>
  <pubsub xmlns='http://jabber.org/protocol/pubsub'>
    <publish node='urn:xmpp:mds:displayed:0'>
      <item id='romeo@montegue.lit'>
        <displayed xmlns='urn:xmpp:mds:displayed:0'>
          <stanza-id xmlns='urn:xmpp:sid:0'
                     by='juliet@capulet.lit'
                     id='0f710f2b-52ed-4d52-b928-784dad74a52b'/>
        </display>
      </item>
    </publish>
    <publish-options>
      <x xmlns='jabber:x:data' type='submit'>
        <field var='FORM_TYPE' type='hidden'>
          <value>http://jabber.org/protocol/pubsub#publish-options</value>
        </field>
        <field var='pubsub#persist_items'>
          <value>true</value>
        </field>
        <field var='pubsub#max_items'>
          <value>max</value>
        </field>
        <field var='pubsub#send_last_published_item'>
          <value>never</value>
        </field>
        <field var='pubsub#access_model'>
          <value>whitelist</value>
        </field>
      </x>
    </publish-options>
  </pubsub>
</iq>
Example 2. Server acknowledges successful storage
<iq to='juliet@capulet.lit/balcony' type='result' id='flag-as-displayed-1'/>

4.3 Retrieving notifications

A client interested in synchronizing the displayed state with other clients SHOULD include the 'urn:xmpp:mds:displayed:0+notify' feature in its Entity Capabilities (XEP-0115) [7], as per Personal Eventing Protocol (XEP-0163) [3] rules.

4.4 Catching up

Upon bind and initial presence a client retrieves all items in the 'urn:xmpp:mds:displayed:0' node to learn what changes to the displayed state have occured while the client was offline.

Example 3. Client retrieves all displayed items
<iq from='juliet@capulet.lit/balcony' type='get' id='catchup-1'>
  <pubsub xmlns='http://jabber.org/protocol/pubsub'>
    <items node='urn:xmpp:mds:displayed:0'/>
  </pubsub>
</iq>
Example 4. Server returns the displayed states for various chat
<iq type='result'
    to='juliet@capulet.lit/balcony'
    id='catchup-1'>
  <pubsub xmlns='http://jabber.org/protocol/pubsub'>
    <items node='urn:xmpp:mds:displayed:0'>
      <item id='romeo@montegue.lit'>
        <displayed xmlns='urn:xmpp:mds:displayed:0'>
          <stanza-id xmlns='urn:xmpp:sid:0'
                     id='0f710f2b-52ed-4d52-b928-784dad74a52b'
                     by='juliet@capulet.lit'/>
        </displayed>
      </item>
      <item id='example@conference.shakespeare.lit'>
        <displayed xmlns='urn:xmpp:mds:displayed:0'
          <stanza-id xmlns='urn:xmpp:sid:0'
                     id='ca21deaf-812c-48f1-8f16-339a674f2864'
                     by='example@conference.shakespeare.lit'/>
        </displayed>
      </item>
    </items>
  </pubsub>
</iq>

4.5 Interaction with Displayed Markers and Server Assist

A Displayed Markers (XEP-0333) [2] displayed marker refers to the message id set by the sender of the message whereas the displayed element defined in this specification refers to the stanza-id injected by the user’s server.

In the likely scenario that a client wishes to share the displayed state with their own devices and the sender of the message, a client SHOULD sent a Displayed Markers (XEP-0333) [2] displayed marker and ensure that the 'urn:xmpp:mds:displayed:0' node gets updated.

4.5.1 Server assist

A Publish-Subscribe (XEP-0060) [8] item publication is a fairly verbose operation for something that is expected to happen rather frequently. Therfore this specification defines an optional way to combine the PEP node item update and the Displayed Marker in one simple message.

4.5.2 Discovering support

Server assisted displayed node updates are an optional feature a user’s server can provide. To signal support the server announces an Entity Capabilities (XEP-0115) [7] feature of 'urn:xmpp:mds:server-assist:0' on the account.

Example 5. Client queries for server features
<iq type='get' id='disco-1' to='juliet@capulet.lit' from='juliet@capulet.lit/balcony'>
  <query xmlns='http://jabber.org/protocol/disco#info'/>
</iq>
Example 6. Server responds with features
<iq type='result' id='disco1' from='juliet@capulet.lit' to='juliet@capulet.lit/balcony'>
  <query xmlns='http://jabber.org/protocol/disco#info'>
    <feature var='urn:xmpp:mds:server-assist:0'/>
  </query>
</iq>

4.5.3 Sending assisted displayed

To update the displayed item in the 'urn:xmpp:mds:displayed:0' PEP node more efficiently a client MAY send a message with the 'to' attribute set to the item id (which is equivalent to the JID of the contact) and with a <displayed/> element qualified by the 'urn:xmpp:mds:displayed:0' namespace. The server MUST strip the <displayed/> element from the message and continue to process it normally. The server MUST publish a PEP item on the 'urn:xmpp:mds:displayed:0' node where the item id is taken from the 'to' attribute and the payload is the <displayed/> element. A client MUST NOT include the <displayed/> element qualified by the 'urn:xmpp:mds:displayed:0' namespace if the message would otherwise be empty. A client that wishes to update the device synchronized displayed state but not inform the sender of the message via Displayed Markers SHOULD use the regular PubSub publication process.

Example 7. Juliet receives a message from Romeo
<message to='juliet@capulet.lit' from='romeo@montegue.lit/orchard' id='the-msg-1'>
  <body>Hi. How are you?</body>
  <markable xmlns='urn:xmpp:chat-markers:0'/>
  <stanza-id xmlns='urn:xmpp:sid:0' by='juliet@capulet.lit' id='0423e3a9-d516-493d-bb06-bee0e51ab9fb'/>
</message>
Example 8. Juliet lets both Romeo and her other devices know she has displayed the message
<message to='romeo@montegue.lit'>
   <displayed xmlns='urn:xmpp:chat-markers:0' id='the-msg-1'/>
   <displayed xmlns='urn:xmpp:mds:displayed:0'>
     <stanza-id xmlns='urn:xmpp:sid:0' by='juliet@capulet.lit' id='0423e3a9-d516-493d-bb06-bee0e51ab9fb'/>
   </displayed>
</message>
Example 9. Juliet’s server strips the displayed element used for server assist and forwards the stanza to Romeo
<message to='romeo@montegue.lit' from='juliet@capulet.let/balcony'>
   <displayed xmlns='urn:xmpp:chat-markers:0' id='the-msg-1'/>
</message>
Example 10. Server sends out PEP notifications to Juliets connected devices
<message from='juliet@capulet.lit' to='juliet@capulet.lit/balcony' type='headline' id='new-displayed-pep-event'>
  <event xmlns='http://jabber.org/protocol/pubsub#event'>
    <items node='urn:xmpp:mds:displayed:0'>
      <item id='romeo@montegue.lit'>
        <displayed xmlns='urn:xmpp:mds:displayed:0'>
          <stanza-id xmlns='urn:xmpp:sid:0' by='juliet@capulet.lit' id='0423e3a9-d516-493d-bb06-bee0e51ab9fb'/>
        </displayed>
      </item>
    </items>
  </event>
</message>

5. Business Rules

5.1 Client

5.2 Server

6. Accessibility Considerations

This specification comes with no accessibility considerations that go beyond what is required of any client (i.e. providing an accessible distinction between read and unread chats).

7. Security Considerations

8. Privacy Considerations

Implementing this specification gives the server the opportunity to perform activity tracking of a similiar scope than implementing Chat State Notifications (XEP-0085) [10] or Displayed Markers (XEP-0333) [2] would.

When using the server assist feature in conjunction with Displayed Markers (XEP-0333) [2] the Privacy Considerations of Display Markers apply.

9. IANA Considerations

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

10. Design Considerations

10.1 Distinct Element for Server Assist

This specification introduces a distinct element to enable server assist instead of utilizing Displayed Markers (XEP-0333) [2] because Displayed Markers use the message id instead of stanza-ids. Translating between message id and stanza-id would require that the message (or parts of it) are archived on the server. Archiving should not be a requirement to offer server assist. (Especially since archived or not can depend on user settings.)

10.2 Server Assist without Display Markers

Server assist is not allowed in messages that would otherwise be empty. Overloading the semantic of sending a stanza to a third party entity solely to perform an action on the account that involves said third party is a dangerous example to set. (For example if server assit fails due to implementation errors a third party can be flooded with messages.) While stripping elements from stanzas is a common requirement on XMPP dropping entire stanzas without error is not.

11. XMPP Registrar Considerations

This specification defines the following XML namespace:

12. XML Schema

REQUIRED for protocol specifications.


Appendices

Appendix A: Document Information

Series
XEP
Number
0490
Publisher
XMPP Standards Foundation
Status
Proposed
Type
Standards Track
Version
0.1.0
Last Updated
2024-03-26
Approving Body
XMPP Council
Dependencies
XMPP Core, XEP-0001, XEP-0163
Supersedes
None
Superseded By
None
Short Name
mds
Source Control
HTML

This document in other formats: XML  PDF

Appendix B: Author Information

Daniel Gultsch
Email
daniel@gultsch.de
JabberID
daniel@gultsch.de

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.

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-0280: Message Carbons <https://xmpp.org/extensions/xep-0280.html>.

2. XEP-0333: Displayed Markers <https://xmpp.org/extensions/xep-0333.html>.

3. XEP-0163: Personal Eventing Protocol <https://xmpp.org/extensions/xep-0163.html>.

4. XEP-0223: Best Practices for Persistent Storage of Private Data via Publish-Subscribe <https://xmpp.org/extensions/xep-0223.html>.

5. XEP-0359: Unique and Stable Stanza IDs <https://xmpp.org/extensions/xep-0359.html>.

6. XEP-0313: Message Archive Management <https://xmpp.org/extensions/xep-0313.html>.

7. XEP-0115: Entity Capabilities <https://xmpp.org/extensions/xep-0115.html>.

8. XEP-0060: Publish-Subscribe <https://xmpp.org/extensions/xep-0060.html>.

9. XEP-0409: IM Routing-NG <https://xmpp.org/extensions/xep-0409.html>.

10. XEP-0085: Chat State Notifications <https://xmpp.org/extensions/xep-0085.html>.

Appendix H: Revision History

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

  1. Version 0.1.0 (2024-03-26)
    XEP Editor: dg
  2. Version 0.0.3 (2024-04-26)

    Split Business Rules into Server and Client sections.

    dg
  3. Version 0.0.2 (2024-03-14)

    Add Accessibility, Privacy and Design Considerations

    dg
  4. Version 0.0.1 (2024-02-21)

    First draft.

    dg

Appendix I: Bib(La)TeX Entry

@report{gultsch2024mds,
  title = {Message Displayed Synchronization},
  author = {Gultsch, Daniel},
  type = {XEP},
  number = {0490},
  version = {0.1.0},
  institution = {XMPP Standards Foundation},
  url = {https://xmpp.org/extensions/xep-0490.html},
  date = {2024-02-21/2024-03-26},
}

END