matrix-spec/specification/modules/receipts.rst

73 lines
1.9 KiB
ReStructuredText
Raw Normal View History

2015-08-28 15:50:31 +02:00
Receipts
--------
2015-08-28 15:50:31 +02:00
Receipts are used to publish which events in a room the user or their devices
have interacted with. For example, which events the user has read. For
efficiency this is done as "up to" markers, i.e. marking a particular event
2015-08-28 16:01:02 +02:00
as, say, ``read`` indicates the user has read all events *up to* that event.
2015-08-28 15:50:31 +02:00
Events
------
{{m_receipt_event}}
Client behaviour
----------------
- When clients should send receipts
- What clients should do when they receive these receipts
2015-08-28 15:50:31 +02:00
Clients will receive receipts in the following format::
2015-08-28 16:01:02 +02:00
{
"type": "m.receipt",
"room_id": <room_id>,
"content": {
<event_id>: {
<receipt_type>: {
<user_id>: { "ts": <ts>, ... },
...
}
},
...
}
}
2015-08-28 15:50:31 +02:00
For efficiency, receipts are batched into one event per room. In the initialSync
and v2 sync APIs the receipts are listed in a separate top level ``receipts``
key. Each ``user_id``, ``receipt_type`` pair must be associated with only a
single ``event_id``. New receipts that come down the event streams are deltas.
Deltas update existing mappings, clobbering based on ``user_id``,
``receipt_type`` pairs.
2015-08-28 15:50:31 +02:00
A client can update the markers for its user by issuing a request::
POST /_matrix/client/v2_alpha/rooms/<room_id>/receipt/read/<event_id>
2015-08-28 16:01:02 +02:00
Where the contents of the ``POST`` will be included in the content sent to
2015-08-28 15:50:31 +02:00
other users. The server will automatically set the ``ts`` field.
Server behaviour
----------------
2015-08-28 15:50:31 +02:00
Receipts are sent across federation as EDUs with type ``m.receipt``. The
format of the EDUs are::
{
<room_id>: {
<receipt_type>: {
<user_id>: { <content> }
},
2015-08-28 16:01:02 +02:00
...
2015-08-28 15:50:31 +02:00
},
...
}
These are always sent as deltas to previously sent receipts.
2015-08-28 15:50:31 +02:00
Security considerations
-----------------------