diff --git a/serverkeyapi/internal/http.go b/serverkeyapi/internal/http.go index 303275712..eef66b76c 100644 --- a/serverkeyapi/internal/http.go +++ b/serverkeyapi/internal/http.go @@ -14,28 +14,16 @@ import ( func (s *ServerKeyAPI) SetupHTTP(internalAPIMux *mux.Router) { internalAPIMux.Handle(api.ServerKeyQueryPublicKeyPath, internal.MakeInternalAPI("queryPublicKeys", func(req *http.Request) util.JSONResponse { - result := map[gomatrixserverlib.PublicKeyLookupRequest]gomatrixserverlib.PublicKeyLookupResult{} request := api.QueryPublicKeysRequest{} response := api.QueryPublicKeysResponse{} if err := json.NewDecoder(req.Body).Decode(&request); err != nil { return util.MessageResponse(http.StatusBadRequest, err.Error()) } - lookup := make(map[gomatrixserverlib.PublicKeyLookupRequest]gomatrixserverlib.Timestamp) - for req, timestamp := range request.Requests { - if res, ok := s.ImmutableCache.GetServerKey(req); ok { - result[req] = res - continue - } - lookup[req] = timestamp - } - keys, err := s.FetchKeys(req.Context(), lookup) + keys, err := s.FetchKeys(req.Context(), request.Requests) if err != nil { return util.ErrorResponse(err) } - for req, res := range keys { - result[req] = res - } - response.Results = result + response.Results = keys return util.JSONResponse{Code: http.StatusOK, JSON: &response} }), )