mirror of
https://github.com/matrix-org/dendrite
synced 2024-06-13 09:58:59 +02:00
Return empty inaccessibleRooms
This commit is contained in:
parent
42a452cec2
commit
52a441a2ef
|
@ -138,7 +138,7 @@ func QueryRoomHierarchy(req *http.Request, device *userapi.Device, roomIDStr str
|
|||
walker = *cachedWalker
|
||||
}
|
||||
|
||||
discoveredRooms, nextWalker, err := rsAPI.QueryNextRoomHierarchyPage(req.Context(), walker, limit)
|
||||
discoveredRooms, _, nextWalker, err := rsAPI.QueryNextRoomHierarchyPage(req.Context(), walker, limit)
|
||||
|
||||
if err != nil {
|
||||
switch err.(type) {
|
||||
|
|
|
@ -146,7 +146,7 @@ func QueryRoomHierarchy(httpReq *http.Request, request *fclient.FederationReques
|
|||
}
|
||||
|
||||
walker := roomserverAPI.NewRoomHierarchyWalker(types.NewServerNameNotDevice(request.Origin()), roomID, suggestedOnly, 1)
|
||||
discoveredRooms, _, err := rsAPI.QueryNextRoomHierarchyPage(httpReq.Context(), walker, -1)
|
||||
discoveredRooms, inaccessibleRooms, _, err := rsAPI.QueryNextRoomHierarchyPage(httpReq.Context(), walker, -1)
|
||||
|
||||
if err != nil {
|
||||
switch err.(type) {
|
||||
|
@ -175,10 +175,9 @@ func QueryRoomHierarchy(httpReq *http.Request, request *fclient.FederationReques
|
|||
return util.JSONResponse{
|
||||
Code: 200,
|
||||
JSON: fclient.RoomHierarchyResponse{
|
||||
Room: discoveredRooms[0],
|
||||
Children: discoveredRooms[1:],
|
||||
// TODO: Actually check which rooms the requesting server/user is not allowed to see.
|
||||
InaccessibleChildren: []string{},
|
||||
Room: discoveredRooms[0],
|
||||
Children: discoveredRooms[1:],
|
||||
InaccessibleChildren: inaccessibleRooms,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
|
@ -141,7 +141,12 @@ type QueryRoomHierarchyAPI interface {
|
|||
//
|
||||
// If returned walker is nil, then there are no more rooms left to traverse. This method does not modify the provided walker, so it
|
||||
// can be cached.
|
||||
QueryNextRoomHierarchyPage(ctx context.Context, walker RoomHierarchyWalker, limit int) ([]fclient.RoomHierarchyRoom, *RoomHierarchyWalker, error)
|
||||
QueryNextRoomHierarchyPage(ctx context.Context, walker RoomHierarchyWalker, limit int) (
|
||||
hierarchyRooms []fclient.RoomHierarchyRoom,
|
||||
inaccessibleRooms []string,
|
||||
hierarchyWalker *RoomHierarchyWalker,
|
||||
err error,
|
||||
)
|
||||
}
|
||||
|
||||
type QueryMembershipAPI interface {
|
||||
|
|
|
@ -39,9 +39,14 @@ import (
|
|||
//
|
||||
// If returned walker is nil, then there are no more rooms left to traverse. This method does not modify the provided walker, so it
|
||||
// can be cached.
|
||||
func (querier *Queryer) QueryNextRoomHierarchyPage(ctx context.Context, walker roomserver.RoomHierarchyWalker, limit int) ([]fclient.RoomHierarchyRoom, *roomserver.RoomHierarchyWalker, error) {
|
||||
func (querier *Queryer) QueryNextRoomHierarchyPage(ctx context.Context, walker roomserver.RoomHierarchyWalker, limit int) (
|
||||
[]fclient.RoomHierarchyRoom,
|
||||
[]string,
|
||||
*roomserver.RoomHierarchyWalker,
|
||||
error,
|
||||
) {
|
||||
if authorised, _ := authorised(ctx, querier, walker.Caller, walker.RootRoomID, nil); !authorised {
|
||||
return nil, nil, roomserver.ErrRoomUnknownOrNotAllowed{Err: fmt.Errorf("room is unknown/forbidden")}
|
||||
return nil, []string{}, nil, roomserver.ErrRoomUnknownOrNotAllowed{Err: fmt.Errorf("room is unknown/forbidden")}
|
||||
}
|
||||
|
||||
discoveredRooms := []fclient.RoomHierarchyRoom{}
|
||||
|
@ -173,7 +178,7 @@ func (querier *Queryer) QueryNextRoomHierarchyPage(ctx context.Context, walker r
|
|||
|
||||
if len(unvisited) == 0 {
|
||||
// If no more rooms to walk, then don't return a walker for future pages
|
||||
return discoveredRooms, nil, nil
|
||||
return discoveredRooms, []string{}, nil, nil
|
||||
} else {
|
||||
// If there are more rooms to walk, then return a new walker to resume walking from (for querying more pages)
|
||||
newWalker := roomserver.RoomHierarchyWalker{
|
||||
|
@ -185,7 +190,7 @@ func (querier *Queryer) QueryNextRoomHierarchyPage(ctx context.Context, walker r
|
|||
Processed: processed,
|
||||
}
|
||||
|
||||
return discoveredRooms, &newWalker, nil
|
||||
return discoveredRooms, []string{}, &newWalker, nil
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue