mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-17 11:53:09 -06:00
Omit empty fields instead
This commit is contained in:
parent
68b6524e14
commit
8123a76117
|
|
@ -247,8 +247,8 @@ func NewJoinResponse() *JoinResponse {
|
||||||
// InviteResponse represents a /sync response for a room which is under the 'invite' key.
|
// InviteResponse represents a /sync response for a room which is under the 'invite' key.
|
||||||
type InviteResponse struct {
|
type InviteResponse struct {
|
||||||
InviteState struct {
|
InviteState struct {
|
||||||
Events json.RawMessage `json:"events"`
|
Events json.RawMessage `json:"events,omitempty"`
|
||||||
} `json:"invite_state"`
|
} `json:"invite_state,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewInviteResponse creates an empty response with initialised arrays.
|
// 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"`
|
InviteRoomState json.RawMessage `json:"invite_room_state"`
|
||||||
}
|
}
|
||||||
if err := json.Unmarshal(ev.Unsigned(), &unsigned); err == nil {
|
if err := json.Unmarshal(ev.Unsigned(), &unsigned); err == nil {
|
||||||
|
if len(unsigned.InviteRoomState) > 0 {
|
||||||
res.InviteState.Events = unsigned.InviteRoomState
|
res.InviteState.Events = unsigned.InviteRoomState
|
||||||
}
|
}
|
||||||
if len(res.InviteState.Events) == 0 || res.InviteState.Events == nil {
|
|
||||||
res.InviteState.Events = json.RawMessage{'[', ']'}
|
|
||||||
}
|
}
|
||||||
return &res
|
return &res
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue