diff options
author | Umar Getagazov <umar@handlerug.me> | 2023-01-17 11:07:42 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-17 09:07:42 +0100 |
commit | 8582c7520abbfca680da9ba16e40a9a92b9fd21c (patch) | |
tree | 6c67f00a80627fe7b2d90b41e3ceea70a833668c | |
parent | eeeb3017d662ad6777c1398b325aa98bc36bae94 (diff) |
Omit state field from `/messages` response if empty (#2940)
The field type is `[ClientEvent]` in the
[spec](https://spec.matrix.org/v1.5/client-server-api/#get_matrixclientv3roomsroomidmessages),
but right now `null` can also be returned. Omit the field completely if
it's empty. Some clients (rightfully) assume it's either not present at
all or it's of the right type (see
https://github.com/matrix-org/matrix-react-sdk/pull/9913).
### Pull Request Checklist
<!-- Please read
https://matrix-org.github.io/dendrite/development/contributing before
submitting your pull request -->
* [x] I have added Go unit tests or [Complement integration
tests](https://github.com/matrix-org/complement) for this PR _or_ I have
justified why this PR doesn't need tests
* The PR is a simple struct tag fix
* [x] Pull request includes a [sign off below using a legally
identifiable
name](https://matrix-org.github.io/dendrite/development/contributing#sign-off)
_or_ I have already signed off privately
Signed-off-by: `Umar Getagazov <umar@handlerug.me>`
Signed-off-by: Umar Getagazov <umar@handlerug.me>
-rw-r--r-- | syncapi/routing/messages.go | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/syncapi/routing/messages.go b/syncapi/routing/messages.go index 0d740ebf..cafba17c 100644 --- a/syncapi/routing/messages.go +++ b/syncapi/routing/messages.go @@ -57,7 +57,7 @@ type messagesResp struct { StartStream string `json:"start_stream,omitempty"` // NOTSPEC: used by Cerulean, so clients can hit /messages then immediately /sync with a latest sync token End string `json:"end,omitempty"` Chunk []gomatrixserverlib.ClientEvent `json:"chunk"` - State []gomatrixserverlib.ClientEvent `json:"state"` + State []gomatrixserverlib.ClientEvent `json:"state,omitempty"` } // OnIncomingMessagesRequest implements the /messages endpoint from the |