Skip to content

Commit

Permalink
Do not recurse into non-spaces in the spaces summary. (#138)
Browse files Browse the repository at this point in the history
Previously m.child.room events in non-space rooms would be
treated as part of the room graph, but this is no longer
supported.
  • Loading branch information
clokep authored Jun 29, 2021
1 parent 8f7fc56 commit 4150aea
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 6 deletions.
47 changes: 41 additions & 6 deletions tests/msc2946_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ func eventKey(srcRoomID, dstRoomID, evType string) string {
// _____|________
// | | |
// R1 SS1 R2
// |
// SS2
// | |
// SS2 R5
// |________
// | |
// R3 R4
Expand All @@ -41,7 +41,6 @@ func eventKey(srcRoomID, dstRoomID, evType string) string {
// - the user is joined to all rooms except R4.
// - R2 <---> Root is a two-way link.
// - The remaining links are just children links.
// - SS1 is marked as a "space", but SS2 is not.
//
// Tests that:
// - Querying the root returns the entire graph
Expand All @@ -61,6 +60,9 @@ func TestClientSpacesSummary(t *testing.T) {
root := alice.CreateRoom(t, map[string]interface{}{
"preset": "public_chat",
"name": "Root",
"creation_content": map[string]interface{}{
"type": "m.space",
},
})
roomNames[root] = "Root"
r1 := alice.CreateRoom(t, map[string]interface{}{
Expand All @@ -85,6 +87,9 @@ func TestClientSpacesSummary(t *testing.T) {
ss2 := alice.CreateRoom(t, map[string]interface{}{
"preset": "public_chat",
"name": "SS2",
"creation_content": map[string]interface{}{
"type": "m.space",
},
})
roomNames[ss2] = "SS2"
r3 := alice.CreateRoom(t, map[string]interface{}{
Expand All @@ -108,6 +113,10 @@ func TestClientSpacesSummary(t *testing.T) {
},
})
roomNames[r4] = "R4"
r5 := bob.CreateRoom(t, map[string]interface{}{
"preset": "public_chat",
"name": "R5",
})

// create the links
rootToR1 := eventKey(root, r1, spaceChildEventType)
Expand All @@ -134,6 +143,14 @@ func TestClientSpacesSummary(t *testing.T) {
"via": []string{"hs1"},
},
})
// Note that this link gets ignored since R2 is not a space.
alice.SendEventSynced(t, r2, b.Event{
Type: spaceChildEventType,
StateKey: &r5,
Content: map[string]interface{}{
"via": []string{"hs1"},
},
})
alice.SendEventSynced(t, r2, b.Event{ // parent link
Type: spaceParentEventType,
StateKey: &root,
Expand Down Expand Up @@ -283,6 +300,9 @@ func TestClientSpacesSummaryJoinRules(t *testing.T) {
root := alice.CreateRoom(t, map[string]interface{}{
"preset": "public_chat",
"name": "Root",
"creation_content": map[string]interface{}{
"type": "m.space",
},
})
r1 := alice.CreateRoom(t, map[string]interface{}{
"preset": "private_chat",
Expand Down Expand Up @@ -438,15 +458,30 @@ func TestFederatedClientSpaces(t *testing.T) {
},
},
}
worldReadableSpace := map[string]interface{}{
"preset": "public_chat",
"creation_content": map[string]interface{}{
"type": "m.space",
},
"initial_state": []map[string]interface{}{
{
"type": "m.room.history_visibility",
"state_key": "",
"content": map[string]string{
"history_visibility": "world_readable",
},
},
},
}
// create the rooms
alice := deployment.Client(t, "hs1", "@alice:hs1")
root := alice.CreateRoom(t, worldReadable)
root := alice.CreateRoom(t, worldReadableSpace)
r1 := alice.CreateRoom(t, worldReadable)
ss1 := alice.CreateRoom(t, worldReadable)
ss1 := alice.CreateRoom(t, worldReadableSpace)
r4 := alice.CreateRoom(t, worldReadable)
bob := deployment.Client(t, "hs2", "@bob:hs2")
r2 := bob.CreateRoom(t, worldReadable)
ss2 := bob.CreateRoom(t, worldReadable)
ss2 := bob.CreateRoom(t, worldReadableSpace)
r3 := bob.CreateRoom(t, worldReadable)

// create the links
Expand Down
9 changes: 9 additions & 0 deletions tests/msc3083_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ func setupRestrictedRoom(t *testing.T, deployment *docker.Deployment) (*client.C
space := alice.CreateRoom(t, map[string]interface{}{
"preset": "public_chat",
"name": "Space",
"creation_content": map[string]interface{}{
"type": "m.space",
},
})
// The room is an unstable room version which supports the restricted join_rule.
room := alice.CreateRoom(t, map[string]interface{}{
Expand Down Expand Up @@ -196,6 +199,9 @@ func TestRestrictedRoomsSpacesSummary(t *testing.T) {
space := alice.CreateRoom(t, map[string]interface{}{
"preset": "public_chat",
"name": "Space",
"creation_content": map[string]interface{}{
"type": "m.space",
},
// World readable to allow peeking without joining.
"initial_state": []map[string]interface{}{
{
Expand Down Expand Up @@ -274,6 +280,9 @@ func TestRestrictedRoomsSpacesSummaryFederation(t *testing.T) {
space := alice.CreateRoom(t, map[string]interface{}{
"preset": "public_chat",
"name": "Space",
"creation_content": map[string]interface{}{
"type": "m.space",
},
"initial_state": []map[string]interface{}{
{
"type": "m.room.history_visibility",
Expand Down

0 comments on commit 4150aea

Please sign in to comment.