@ -1999,7 +1999,7 @@ This specification describes the following relationship types:
* [Threads ](#threading ).
* [Threads ](#threading ).
* [References ](#reference-relations )
* [References ](#reference-relations )
#### Aggregations
#### Aggregations of child events
{{% added-in v="1.3" %}}
{{% added-in v="1.3" %}}
@ -2013,14 +2013,12 @@ of times that `key` was used by child events.
The actual aggregation format depends on the `rel_type` .
The actual aggregation format depends on the `rel_type` .
Aggregations are sometimes automatically included by a server alongside the parent
When an event is served to the client through the APIs listed below, a
event. This is known as a "bundled aggregation" or "bundle" for simplicity. The
`m.relations` property is included under `unsigned` if the event has child
act of doing this is "bundling".
events which can be aggregated and point at it. The `m.relations` property is
an object keyed by `rel_type` and value being the type-specific aggregated
When an event is served to the client through the APIs listed below, a `m.relations` property
format for that `rel_type` . This `m.relations` property is known as a "bundled
is included under `unsigned` if the event has child events which can be aggregated and point
aggregation".
at it. The `m.relations` property is an object keyed by `rel_type` and value being the type-specific
aggregated format for that `rel_type` , also known as the bundle.
For example (unimportant fields not included):
For example (unimportant fields not included):
@ -2056,10 +2054,10 @@ For example (unimportant fields not included):
}
}
```
```
Note how the `org.example.possible_annotations` bundle is an array compared to the
Note how the `org.example.possible_annotations` aggregation is an array, while in the
`org.example.possible_thread` bundle where the server is summarising the state of
`org.example.possible_thread` aggregation where the server is summarising the state of
the relationship in a single object. Both are valid ways to aggregate, and their
the relationship in a single object. Both are valid ways to aggregate: the format of an
exact types depend on the `rel_type` .
aggregation depends on the `rel_type` .
{{% boxes/warning %}}
{{% boxes/warning %}}
State events do not currently receive bundled aggregations. This is not
State events do not currently receive bundled aggregations. This is not
@ -2086,11 +2084,11 @@ such as `/initialSync`.
While this functionality allows the client to see what was known to the server at the
While this functionality allows the client to see what was known to the server at the
time of handling, the client should continue to aggregate locally if it is aware of
time of handling, the client should continue to aggregate locally if it is aware of
the relationship type's behaviour. For example, a client might increment a `count`
the relationship type's behaviour. For example, a client might internally in crement a `count`
on a parent event's bundle if it saw a new child event which referenced that parent.
in a parent event's aggregation data if it saw a new child event which referenced that parent.
The bundle provided by the server only includes child events which were known at the
The aggregation provided by the server only includes child events which were known at the
time the client would receive the bundle . For example, in a single `/sync` response
time the client would receive the aggregation . For example, in a single `/sync` response
with the parent and multiple child events the child events would have already been
with the parent and multiple child events the child events would have already been
included on the parent's `m.relations` field. Events received in future syncs would
included on the parent's `m.relations` field. Events received in future syncs would
need to be aggregated manually by the client.
need to be aggregated manually by the client.
@ -2100,7 +2098,7 @@ Events from [ignored users](#ignoring-users) do not appear in the aggregation
from the server, however clients might still have events from ignored users cached. Like
from the server, however clients might still have events from ignored users cached. Like
with normal events, clients will need to de-aggregate child events sent by ignored users to
with normal events, clients will need to de-aggregate child events sent by ignored users to
avoid them being considered in counts. Servers must additionally ensure they do not
avoid them being considered in counts. Servers must additionally ensure they do not
consider child events from ignored users when preparing a bundle for the client.
consider child events from ignored users when preparing an aggregation for the client.
{{% /boxes/note %}}
{{% /boxes/note %}}
When a parent event is redacted, the child events which pointed to that parent remain, however
When a parent event is redacted, the child events which pointed to that parent remain, however
@ -2109,7 +2107,7 @@ to de-aggregate or disassociate the event once the relationship is lost. Clients
aggregation or which handle redactions locally should do the same.
aggregation or which handle redactions locally should do the same.
It is suggested that clients perform local echo on aggregations — for instance, aggregating
It is suggested that clients perform local echo on aggregations — for instance, aggregating
a new child event into a bundle optimistically until the server returns a failure or the client
a new child event into a parent event optimistically until the server returns a failure or the client
gives up on sending the event, at which point the event should be de-aggregated and an
gives up on sending the event, at which point the event should be de-aggregated and an
error or similar shown. The client should be cautious to not aggregate an event twice if
error or similar shown. The client should be cautious to not aggregate an event twice if
it has already optimistically aggregated the event. Clients are encouraged to take this
it has already optimistically aggregated the event. Clients are encouraged to take this
@ -2118,7 +2116,7 @@ likely using the transaction ID as a temporary event ID until a proper event ID
{{% boxes/warning %}}
{{% boxes/warning %}}
Due to history visibility restrictions, child events might not be visible to the user
Due to history visibility restrictions, child events might not be visible to the user
if they are in a section of history the user cannot see. This means any bundle s which would
if they are in a section of history the user cannot see. This means any aggregation s which would
normally include those events will be lacking them and the client will not be able to
normally include those events will be lacking them and the client will not be able to
locally aggregate the events either — relating events of importance (such as votes) should
locally aggregate the events either — relating events of importance (such as votes) should
take into consideration history visibility.
take into consideration history visibility.