`/sync`: `rooms.joined.state` overlaps with `rooms.joined.timeline`
The spec for the sync endpoint says that the rooms.joined.state field should be
Updates to the state, between the time indicated by the
since
parameter, and the start of the timeline (or all state up to the start of the timeline, ifsince
is not given, orfull_state
is true).
Instead of updates between since and the start of the timeline, we're returning updates between since and the end of the timeline.
Steps to reproduce
- Create a room and generate several state events (room topic changes are convenient for this)
- Make a call to
/v3/sync
without asince
parameter - Observe the set of state events included in
rooms.joined.$your_room.timeline
and compare it to the set of state events included inrooms.joined.$your_room.state
. Some events that are present intimeline
are also present instate
.
Notes
The spec includes this block with an explanation of the reasoning behind this design:
An early design of this specification made the state list represent the room state at the end of the returned timeline, instead of the start. This was unsatisfactory because it led to duplication of events between the state list and the timeline, but more importantly, it made it difficult for clients to show the timeline correctly.
In particular, consider a returned timeline [M0, S1, M2], where M0 and M2 are both messages sent by the same user, and S1 is a state event where that user changes their displayname. If the state list represents the room state at the end of the timeline, the client must take a copy of the state dictionary, and rewind S1, in order to correctly calculate the display name for M0.