From 9b79f9a88357bfebb57243205b7c15dd4b4303e2 Mon Sep 17 00:00:00 2001 From: Matthew Hodgson Date: Mon, 31 Aug 2020 12:27:39 +0300 Subject: [PATCH] add server_name param --- clientapi/routing/peekroom.go | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/clientapi/routing/peekroom.go b/clientapi/routing/peekroom.go index 98983c60a..17bbaef40 100644 --- a/clientapi/routing/peekroom.go +++ b/clientapi/routing/peekroom.go @@ -33,6 +33,17 @@ func PeekRoomByIDOrAlias( accountDB accounts.Database, roomIDOrAlias string, ) util.JSONResponse { + // Check to see if any ?server_name= query parameters were + // given in the request. + if serverNames, ok := req.URL.Query()["server_name"]; ok { + for _, serverName := range serverNames { + peekReq.ServerNames = append( + peekReq.ServerNames, + gomatrixserverlib.ServerName(serverName), + ) + } + } + // if this is a remote roomIDOrAlias, we have to ask the roomserver (or federation sender?) to // to call /peek and /state on the remote server. // TODO: in future we could skip this if we know we're already participating in the room, @@ -46,7 +57,7 @@ func PeekRoomByIDOrAlias( } peekRes := roomserverAPI.PerformPeekResponse{} - // Ask the roomserver to perform the join. + // Ask the roomserver to perform the peek. rsAPI.PerformPeek(req.Context(), &peekReq, &peekRes) if peekRes.Error != nil { return peekRes.Error.JSONResponse() @@ -66,6 +77,6 @@ func PeekRoomByIDOrAlias( // TODO: Put the response struct somewhere internal. JSON: struct { RoomID string `json:"room_id"` - }{joinRes.RoomID}, + }{peekRes.RoomID}, } }