diff --git a/src/github.com/matrix-org/dendrite/roomserver/api/public_room.go b/src/github.com/matrix-org/dendrite/roomserver/api/public_room.go index ba8ec7421..b9edb62b4 100644 --- a/src/github.com/matrix-org/dendrite/roomserver/api/public_room.go +++ b/src/github.com/matrix-org/dendrite/roomserver/api/public_room.go @@ -49,7 +49,7 @@ type GetPublicRoomsRequest struct { // GetPublicRoomsResponse is a response to GetPublicRooms type GetPublicRoomsResponse struct { - Chunk []PublicRoomsChunk `json:"chunk"` + Chunks []PublicRoomsChunk `json:"chunk"` NextBatch string `json:"next_batch"` PrevBatch string `json:"prev_batch"` TotalRoomCountEstimate int64 `json:"total_room_count_estimate"` @@ -57,15 +57,15 @@ type GetPublicRoomsResponse struct { // PublicRoomsChunk implements the PublicRoomsChunk structure from the Matrix spec type PublicRoomsChunk struct { - RoomID string `json:"room_id"` - Aliases []string `json:"aliases"` - CanonicalAlias string `json:"canonical_alias"` - Name string `json:"name"` - Topic string `json:"topic"` - AvatarURL string `json:"avatar_url"` - JoinedMembers int64 `json:"num_joined_members"` - WorldReadable bool `json:"world_readable"` - GuestCanJoin bool `json:"guest_can_join"` + RoomID string `json:"room_id"` + Aliases []string `json:"aliases"` + CanonicalAlias string `json:"canonical_alias"` + Name string `json:"name"` + Topic string `json:"topic"` + AvatarURL string `json:"avatar_url"` + NumJoinedMembers int64 `json:"num_joined_members"` + WorldReadable bool `json:"world_readable"` + GuestCanJoin bool `json:"guest_can_join"` } // RoomserverPublicRoomAPI is used to update or retrieve the visibility setting diff --git a/src/github.com/matrix-org/dendrite/roomserver/publicroom/public_room.go b/src/github.com/matrix-org/dendrite/roomserver/publicroom/public_room.go index a318489a6..cc1584836 100644 --- a/src/github.com/matrix-org/dendrite/roomserver/publicroom/public_room.go +++ b/src/github.com/matrix-org/dendrite/roomserver/publicroom/public_room.go @@ -108,6 +108,29 @@ func (r *RoomserverPublicRoomAPI) GetPublicRooms( req *api.GetPublicRoomsRequest, response *api.GetPublicRoomsResponse, ) error { + roomIDs, err := r.DB.GetPublicRoomIDs() + if err != nil { + return err + } + + rooms, err := r.DB.GetAliasesFromRoomIDs(roomIDs) + if err != nil { + return err + } + + var chunks []api.PublicRoomsChunk + for room, aliases := range rooms { + chunk := api.PublicRoomsChunk{ + RoomID: room, + Aliases: aliases, + NumJoinedMembers: 0, + WorldReadable: true, + GuestCanJoin: true, + } + chunks = append(chunks, chunk) + } + + response.Chunks = chunks return nil }