Mobile: spaces; /hierarchy always sends children_state
Mobile: - The room list's title picks a space: All chats, or one space, which narrows the list to its rooms (and its subspaces' rooms). - A space browser over /hierarchy: the rooms of a space and of its subspaces, joined or joinable, with Join; for those who may, adding an existing room or a new one to the space. - New space in the new-chat sheet; invites to spaces show with the other invites and open the space when joined. - Fixes several setState calls that were handed a Future (reloading the members, sessions, push distributor, threads), which Flutter rejects. Server: /hierarchy left out children_state for a room without children. The spec requires it on every room (an empty list), and SpaceRoom's omitempty dropped empty lists too, despite its comment. The famedly Dart SDK fails to parse such a response. The client API now wraps each room so the field is always written; the federation response, which wants it left out of the children it lists, is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
4271d2ab17
commit
879e22141b
10 files changed
+628
-33
No files matched your search
@@ -180,3 +180,32 @@ func TestRoomSummary(t *testing.T) {
|
||||
t.Errorf("alice's summary of her own room says membership %v", jsonBody(t, rec)["membership"])
|
||||
}
|
||||
}
|
||||
|
||||
// children_state is required on every room /hierarchy returns, an empty
|
||||
// list for one with no children: clients that parse the response strictly
|
||||
// (the famedly Dart SDK) fail on a room without it.
|
||||
func TestSpaceHierarchyEmptyChildrenState(t *testing.T) {
|
||||
ts := newTestServer(t, nil)
|
||||
alice := ts.register("alice", "correct-horse-battery-staple")
|
||||
space := ts.createSpace(alice, "Empty space", false)
|
||||
room := ts.createRoom(alice, map[string]any{"name": "Leaf"})
|
||||
ts.addChild(alice, space, room, nil)
|
||||
|
||||
rec := ts.get("/_matrix/client/v1/rooms/"+url.PathEscape(space)+"/hierarchy", alice.AccessToken)
|
||||
expectStatus(t, rec, http.StatusOK)
|
||||
raw := decode[struct {
|
||||
Rooms []map[string]any `json:"rooms"`
|
||||
}](t, rec)
|
||||
if len(raw.Rooms) != 2 {
|
||||
t.Fatalf("got %d rooms, want the space and its child", len(raw.Rooms))
|
||||
}
|
||||
for _, r := range raw.Rooms {
|
||||
children, ok := r["children_state"].([]any)
|
||||
if !ok {
|
||||
t.Errorf("%v: children_state = %#v, want a list", r["room_id"], r["children_state"])
|
||||
}
|
||||
if r["room_id"] == room && len(children) != 0 {
|
||||
t.Errorf("the leaf room has children_state %v", children)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user