From 18e3c40da43017a9e1abe775a406844aca5e1643 Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Tue, 1 Mar 2022 14:22:59 +0000 Subject: [PATCH] Always send [] from federated rooms, not null --- setup/mscs/msc2946/msc2946.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/setup/mscs/msc2946/msc2946.go b/setup/mscs/msc2946/msc2946.go index 3bb56f4b3..bf26e9910 100644 --- a/setup/mscs/msc2946/msc2946.go +++ b/setup/mscs/msc2946/msc2946.go @@ -426,6 +426,18 @@ func (w *walker) federatedRoomInfo(roomID string, vias []string) (*gomatrixserve util.GetLogger(w.ctx).WithError(err).Warnf("failed to call MSC2946Spaces on server %s", serverName) continue } + // ensure nil slices are empty as we send this to the client sometimes + if res.Room.ChildrenState == nil { + res.Room.ChildrenState = []gomatrixserverlib.MSC2946StrippedEvent{} + } + for i := 0; i < len(res.Children); i++ { + child := res.Children[i] + if child.ChildrenState == nil { + child.ChildrenState = []gomatrixserverlib.MSC2946StrippedEvent{} + } + res.Children[i] = child + } + return &res, nil } return nil, nil