2015-10-14 14:26:58 +02:00
|
|
|
Event Structure
|
|
|
|
|
===============
|
2014-10-10 01:38:04 +02:00
|
|
|
|
2014-11-18 06:08:36 +01:00
|
|
|
All communication in Matrix is expressed in the form of data objects called
|
2014-11-12 14:32:47 +01:00
|
|
|
Events. These are the fundamental building blocks common to the client-server,
|
|
|
|
|
server-server and application-service APIs, and are described below.
|
2014-10-10 01:38:04 +02:00
|
|
|
|
2015-05-21 16:51:23 +02:00
|
|
|
{{common_event_fields}}
|
2014-10-10 01:38:04 +02:00
|
|
|
|
2015-05-21 16:51:23 +02:00
|
|
|
{{common_room_event_fields}}
|
2014-10-10 01:38:04 +02:00
|
|
|
|
2015-05-21 16:51:23 +02:00
|
|
|
{{common_state_event_fields}}
|
2014-10-10 01:38:04 +02:00
|
|
|
|
|
|
|
|
|
2015-10-29 19:38:33 +01:00
|
|
|
Differences between /v1 and /v2 events
|
|
|
|
|
--------------------------------------
|
|
|
|
|
|
|
|
|
|
There are a few differences between how events are formatted for sending
|
|
|
|
|
between servers over federation and how they are formatted for sending between
|
|
|
|
|
a server and its clients.
|
|
|
|
|
|
|
|
|
|
Additionally there are a few differences between the format of events in the
|
|
|
|
|
responses to client APIs with a /v1 prefix and responses APIs with a /v2
|
|
|
|
|
prefix.
|
|
|
|
|
|
|
|
|
|
Events in responses for APIs with the /v2 prefix are generated from an event
|
|
|
|
|
formatted for federation by:
|
|
|
|
|
|
|
|
|
|
* Removing the following keys:
|
|
|
|
|
``auth_events``, ``prev_events``, ``hashes``, ``signatures``, ``depth``,
|
2015-11-18 16:15:21 +01:00
|
|
|
``origin``, ``prev_state``.
|
|
|
|
|
* Adding an ``age`` to the ``unsigned`` object which gives the time in
|
2015-11-16 00:30:29 +01:00
|
|
|
milliseconds that has elapsed since the event was sent.
|
2015-11-18 16:15:21 +01:00
|
|
|
* Adding ``prev_content`` and ``prev_sender`` to the ``unsigned`` object if the
|
|
|
|
|
event is a ``state event``, which give the previous content and previous
|
|
|
|
|
sender of that state key
|
|
|
|
|
* Adding a ``redacted_because`` to the ``unsigned`` object if the event was
|
2015-10-29 19:38:33 +01:00
|
|
|
redacted which gives the event that redacted it.
|
2015-11-18 16:15:21 +01:00
|
|
|
* Adding a ``transaction_id`` to the ``unsigned`` object if the event was sent
|
|
|
|
|
by the client requesting it.
|
2015-10-29 19:38:33 +01:00
|
|
|
|
|
|
|
|
Events in responses for APIs with the /v1 prefix are generated from an event
|
|
|
|
|
formatted for the /v2 prefix by:
|
|
|
|
|
|
2015-11-18 16:15:21 +01:00
|
|
|
* Moving the folling keys from the ``unsigned`` object to the top level event
|
|
|
|
|
object: ``age``, ``redacted_because``, ``replaces_state``, ``prev_content``.
|
|
|
|
|
* Removing the ``unsigned`` object.
|
2015-10-29 19:45:53 +01:00
|
|
|
* Rename the ``sender`` key to ``user_id``.
|
2015-10-29 19:38:33 +01:00
|
|
|
* If the event was an ``m.room.member`` with ``membership`` set to ``invite``
|
|
|
|
|
then adding a ``invite_room_state`` key to the top level event object.
|
|
|
|
|
|
|
|
|
|
|
2015-10-14 17:15:55 +02:00
|
|
|
Size limits
|
|
|
|
|
-----------
|
|
|
|
|
|
|
|
|
|
The total size of any event MUST NOT exceed 65 KB. There are additional
|
|
|
|
|
restrictions on sizes per key:
|
|
|
|
|
|
2015-10-23 11:51:31 +02:00
|
|
|
- ``user_id`` MUST NOT exceed 255 bytes (including domain).
|
|
|
|
|
- ``room_id`` MUST NOT exceed 255 bytes.
|
|
|
|
|
- ``state_key`` MUST NOT exceed 255 bytes.
|
|
|
|
|
- ``type`` MUST NOT exceed 255 bytes.
|
|
|
|
|
- ``event_id`` MUST NOT exceed 255 bytes.
|
2015-10-14 17:15:55 +02:00
|
|
|
|
2015-10-15 10:58:39 +02:00
|
|
|
Some event types have additional size restrictions which are specified in
|
2015-10-14 17:15:55 +02:00
|
|
|
the description of the event. Additional keys have no limit other than that
|
|
|
|
|
implied by the total 65 KB limit on events.
|
|
|
|
|
|
2014-10-10 01:38:04 +02:00
|
|
|
Room Events
|
|
|
|
|
-----------
|
|
|
|
|
.. NOTE::
|
|
|
|
|
This section is a work in progress.
|
|
|
|
|
|
|
|
|
|
This specification outlines several standard event types, all of which are
|
|
|
|
|
prefixed with ``m.``
|
|
|
|
|
|
2015-09-23 11:48:49 +02:00
|
|
|
{{m_room_aliases_event}}
|
|
|
|
|
|
2015-09-23 12:30:07 +02:00
|
|
|
{{m_room_canonical_alias_event}}
|
2015-09-23 11:48:49 +02:00
|
|
|
|
|
|
|
|
{{m_room_create_event}}
|
|
|
|
|
|
|
|
|
|
{{m_room_join_rules_event}}
|
|
|
|
|
|
|
|
|
|
{{m_room_member_event}}
|
|
|
|
|
|
|
|
|
|
{{m_room_power_levels_event}}
|
|
|
|
|
|
|
|
|
|
{{m_room_redaction_event}}
|
2014-10-10 01:38:04 +02:00
|
|
|
|