You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
78 lines
2.1 KiB
ReStructuredText
78 lines
2.1 KiB
ReStructuredText
9 years ago
|
Receipts
|
||
9 years ago
|
--------
|
||
9 years ago
|
|
||
|
Receipts are used to publish which events in a room the user or their devices
|
||
9 years ago
|
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
|
||
9 years ago
|
as, say, ``read`` indicates the user has read all events *up to* that event.
|
||
9 years ago
|
|
||
|
Client-Server API
|
||
9 years ago
|
~~~~~~~~~~~~~~~~~
|
||
9 years ago
|
|
||
|
Clients will receive receipts in the following format::
|
||
|
|
||
9 years ago
|
{
|
||
|
"type": "m.receipt",
|
||
|
"room_id": <room_id>,
|
||
|
"content": {
|
||
|
<event_id>: {
|
||
|
<receipt_type>: {
|
||
|
<user_id>: { "ts": <ts>, ... },
|
||
|
...
|
||
|
}
|
||
|
},
|
||
|
...
|
||
|
}
|
||
|
}
|
||
|
|
||
|
For example::
|
||
|
|
||
9 years ago
|
{
|
||
|
"type": "m.receipt",
|
||
9 years ago
|
"room_id": "!KpjVgQyZpzBwvMBsnT:matrix.org",
|
||
9 years ago
|
"content": {
|
||
|
"$1435641916114394fHBLK:matrix.org": {
|
||
|
"read": {
|
||
|
"@erikj:jki.re": { "ts": 1436451550453 },
|
||
|
...
|
||
|
}
|
||
|
},
|
||
|
...
|
||
|
}
|
||
|
}
|
||
|
|
||
|
For efficiency, receipts are batched into one event per room. In the initialSync
|
||
9 years ago
|
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.
|
||
9 years ago
|
|
||
|
|
||
|
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>
|
||
|
|
||
9 years ago
|
Where the contents of the ``POST`` will be included in the content sent to
|
||
9 years ago
|
other users. The server will automatically set the ``ts`` field.
|
||
|
|
||
|
|
||
|
Server-Server API
|
||
9 years ago
|
~~~~~~~~~~~~~~~~~
|
||
9 years ago
|
|
||
|
Receipts are sent across federation as EDUs with type ``m.receipt``. The
|
||
|
format of the EDUs are::
|
||
|
|
||
|
{
|
||
|
<room_id>: {
|
||
|
<receipt_type>: {
|
||
|
<user_id>: { <content> }
|
||
|
},
|
||
9 years ago
|
...
|
||
9 years ago
|
},
|
||
|
...
|
||
|
}
|
||
|
|
||
9 years ago
|
These are always sent as deltas to previously sent receipts.
|
||
9 years ago
|
|