mirror of
https://github.com/matrix-org/dendrite.git
synced 2026-01-16 10:33:11 -06:00
Add MarshalJSON for LeaveResponse
This commit is contained in:
parent
d5b5708329
commit
fe774899d3
|
|
@ -540,6 +540,18 @@ type LeaveResponse struct {
|
||||||
Timeline *Timeline `json:"timeline,omitempty"`
|
Timeline *Timeline `json:"timeline,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (lr LeaveResponse) MarshalJSON() ([]byte, error) {
|
||||||
|
type alias LeaveResponse
|
||||||
|
a := alias(lr)
|
||||||
|
if lr.State != nil && len(lr.State.Events) == 0 {
|
||||||
|
a.State = nil
|
||||||
|
}
|
||||||
|
if lr.Timeline != nil && len(lr.Timeline.Events) == 0 {
|
||||||
|
a.Timeline = nil
|
||||||
|
}
|
||||||
|
return json.Marshal(a)
|
||||||
|
}
|
||||||
|
|
||||||
// NewLeaveResponse creates an empty response with initialised arrays.
|
// NewLeaveResponse creates an empty response with initialised arrays.
|
||||||
func NewLeaveResponse() *LeaveResponse {
|
func NewLeaveResponse() *LeaveResponse {
|
||||||
res := LeaveResponse{
|
res := LeaveResponse{
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue