From 8123a761173fe4db288624f45d226d7eba465f0c Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Wed, 22 Apr 2020 17:49:09 +0100 Subject: [PATCH] Omit empty fields instead --- syncapi/types/types.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/syncapi/types/types.go b/syncapi/types/types.go index cc78c7eb7..dd2147175 100644 --- a/syncapi/types/types.go +++ b/syncapi/types/types.go @@ -247,8 +247,8 @@ func NewJoinResponse() *JoinResponse { // InviteResponse represents a /sync response for a room which is under the 'invite' key. type InviteResponse struct { InviteState struct { - Events json.RawMessage `json:"events"` - } `json:"invite_state"` + Events json.RawMessage `json:"events,omitempty"` + } `json:"invite_state,omitempty"` } // NewInviteResponse creates an empty response with initialised arrays. @@ -258,10 +258,9 @@ func NewInviteResponse(ev gomatrixserverlib.HeaderedEvent) *InviteResponse { InviteRoomState json.RawMessage `json:"invite_room_state"` } if err := json.Unmarshal(ev.Unsigned(), &unsigned); err == nil { - res.InviteState.Events = unsigned.InviteRoomState - } - if len(res.InviteState.Events) == 0 || res.InviteState.Events == nil { - res.InviteState.Events = json.RawMessage{'[', ']'} + if len(unsigned.InviteRoomState) > 0 { + res.InviteState.Events = unsigned.InviteRoomState + } } return &res }