Remove room version cquery
This commit is contained in:
parent
63cbc614ff
commit
a170d58733
|
@ -261,16 +261,6 @@ type QueryRoomVersionCapabilitiesResponse struct {
|
||||||
AvailableRoomVersions map[gomatrixserverlib.RoomVersion]string `json:"available"`
|
AvailableRoomVersions map[gomatrixserverlib.RoomVersion]string `json:"available"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// QueryRoomVersionForRoom asks for the room version for a given room.
|
|
||||||
type QueryRoomVersionForRoomRequest struct {
|
|
||||||
RoomID string `json:"room_id"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// QueryRoomVersionCapabilitiesResponse is a response to QueryServersInRoomAtEventResponse
|
|
||||||
type QueryRoomVersionForRoomResponse struct {
|
|
||||||
RoomVersion gomatrixserverlib.RoomVersion `json:"room_version"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// RoomserverQueryAPI is used to query information from the room server.
|
// RoomserverQueryAPI is used to query information from the room server.
|
||||||
type RoomserverQueryAPI interface {
|
type RoomserverQueryAPI interface {
|
||||||
// Query the latest events and state for a room from the room server.
|
// Query the latest events and state for a room from the room server.
|
||||||
|
@ -357,13 +347,6 @@ type RoomserverQueryAPI interface {
|
||||||
request *QueryRoomVersionCapabilitiesRequest,
|
request *QueryRoomVersionCapabilitiesRequest,
|
||||||
response *QueryRoomVersionCapabilitiesResponse,
|
response *QueryRoomVersionCapabilitiesResponse,
|
||||||
) error
|
) error
|
||||||
|
|
||||||
// Asks for the room version for a given room.
|
|
||||||
QueryRoomVersionForRoom(
|
|
||||||
ctx context.Context,
|
|
||||||
request *QueryRoomVersionForRoomRequest,
|
|
||||||
response *QueryRoomVersionForRoomResponse,
|
|
||||||
) error
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// RoomserverQueryLatestEventsAndStatePath is the HTTP path for the QueryLatestEventsAndState API.
|
// RoomserverQueryLatestEventsAndStatePath is the HTTP path for the QueryLatestEventsAndState API.
|
||||||
|
@ -402,9 +385,6 @@ const RoomserverQueryServersInRoomAtEventPath = "/api/roomserver/queryServersInR
|
||||||
// RoomserverQueryRoomVersionCapabilitiesPath is the HTTP path for the QueryRoomVersionCapabilities API
|
// RoomserverQueryRoomVersionCapabilitiesPath is the HTTP path for the QueryRoomVersionCapabilities API
|
||||||
const RoomserverQueryRoomVersionCapabilitiesPath = "/api/roomserver/queryRoomVersionCapabilities"
|
const RoomserverQueryRoomVersionCapabilitiesPath = "/api/roomserver/queryRoomVersionCapabilities"
|
||||||
|
|
||||||
// RoomserverQueryRoomVersionCapabilitiesPath is the HTTP path for the QueryRoomVersionCapabilities API
|
|
||||||
const RoomserverQueryRoomVersionForRoomPath = "/api/roomserver/queryRoomVersionForRoom"
|
|
||||||
|
|
||||||
// NewRoomserverQueryAPIHTTP creates a RoomserverQueryAPI implemented by talking to a HTTP POST API.
|
// NewRoomserverQueryAPIHTTP creates a RoomserverQueryAPI implemented by talking to a HTTP POST API.
|
||||||
// If httpClient is nil then it uses the http.DefaultClient
|
// If httpClient is nil then it uses the http.DefaultClient
|
||||||
func NewRoomserverQueryAPIHTTP(roomserverURL string, httpClient *http.Client) RoomserverQueryAPI {
|
func NewRoomserverQueryAPIHTTP(roomserverURL string, httpClient *http.Client) RoomserverQueryAPI {
|
||||||
|
@ -574,16 +554,3 @@ func (h *httpRoomserverQueryAPI) QueryRoomVersionCapabilities(
|
||||||
apiURL := h.roomserverURL + RoomserverQueryRoomVersionCapabilitiesPath
|
apiURL := h.roomserverURL + RoomserverQueryRoomVersionCapabilitiesPath
|
||||||
return commonHTTP.PostJSON(ctx, span, h.httpClient, apiURL, request, response)
|
return commonHTTP.PostJSON(ctx, span, h.httpClient, apiURL, request, response)
|
||||||
}
|
}
|
||||||
|
|
||||||
// QueryRoomVersionForRoom implements RoomServerQueryAPI
|
|
||||||
func (h *httpRoomserverQueryAPI) QueryRoomVersionForRoom(
|
|
||||||
ctx context.Context,
|
|
||||||
request *QueryRoomVersionForRoomRequest,
|
|
||||||
response *QueryRoomVersionForRoomResponse,
|
|
||||||
) error {
|
|
||||||
span, ctx := opentracing.StartSpanFromContext(ctx, "QueryRoomVersionForRoom")
|
|
||||||
defer span.Finish()
|
|
||||||
|
|
||||||
apiURL := h.roomserverURL + RoomserverQueryRoomVersionForRoomPath
|
|
||||||
return commonHTTP.PostJSON(ctx, span, h.httpClient, apiURL, request, response)
|
|
||||||
}
|
|
||||||
|
|
|
@ -804,20 +804,6 @@ func (r *RoomserverQueryAPI) QueryRoomVersionCapabilities(
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// QueryRoomVersionCapabilities implements api.RoomserverQueryAPI
|
|
||||||
func (r *RoomserverQueryAPI) QueryRoomVersionForRoom(
|
|
||||||
ctx context.Context,
|
|
||||||
request *api.QueryRoomVersionForRoomRequest,
|
|
||||||
response *api.QueryRoomVersionForRoomResponse,
|
|
||||||
) error {
|
|
||||||
roomVersion, err := r.DB.GetRoomVersionForRoom(ctx, request.RoomID)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
response.RoomVersion = roomVersion
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetupHTTP adds the RoomserverQueryAPI handlers to the http.ServeMux.
|
// SetupHTTP adds the RoomserverQueryAPI handlers to the http.ServeMux.
|
||||||
// nolint: gocyclo
|
// nolint: gocyclo
|
||||||
func (r *RoomserverQueryAPI) SetupHTTP(servMux *http.ServeMux) {
|
func (r *RoomserverQueryAPI) SetupHTTP(servMux *http.ServeMux) {
|
||||||
|
@ -989,18 +975,4 @@ func (r *RoomserverQueryAPI) SetupHTTP(servMux *http.ServeMux) {
|
||||||
return util.JSONResponse{Code: http.StatusOK, JSON: &response}
|
return util.JSONResponse{Code: http.StatusOK, JSON: &response}
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
servMux.Handle(
|
|
||||||
api.RoomserverQueryRoomVersionForRoomPath,
|
|
||||||
common.MakeInternalAPI("QueryRoomVersionForRoom", func(req *http.Request) util.JSONResponse {
|
|
||||||
var request api.QueryRoomVersionForRoomRequest
|
|
||||||
var response api.QueryRoomVersionForRoomResponse
|
|
||||||
if err := json.NewDecoder(req.Body).Decode(&request); err != nil {
|
|
||||||
return util.ErrorResponse(err)
|
|
||||||
}
|
|
||||||
if err := r.QueryRoomVersionForRoom(req.Context(), &request, &response); err != nil {
|
|
||||||
return util.ErrorResponse(err)
|
|
||||||
}
|
|
||||||
return util.JSONResponse{Code: http.StatusOK, JSON: &response}
|
|
||||||
}),
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,11 +43,11 @@ var roomVersions = map[gomatrixserverlib.RoomVersion]RoomVersionDescription{
|
||||||
Stable: true,
|
Stable: true,
|
||||||
},
|
},
|
||||||
gomatrixserverlib.RoomVersionV3: RoomVersionDescription{
|
gomatrixserverlib.RoomVersionV3: RoomVersionDescription{
|
||||||
Supported: false,
|
Supported: true,
|
||||||
Stable: false,
|
Stable: false,
|
||||||
},
|
},
|
||||||
gomatrixserverlib.RoomVersionV4: RoomVersionDescription{
|
gomatrixserverlib.RoomVersionV4: RoomVersionDescription{
|
||||||
Supported: false,
|
Supported: true,
|
||||||
Stable: false,
|
Stable: false,
|
||||||
},
|
},
|
||||||
gomatrixserverlib.RoomVersionV5: RoomVersionDescription{
|
gomatrixserverlib.RoomVersionV5: RoomVersionDescription{
|
||||||
|
@ -59,7 +59,7 @@ var roomVersions = map[gomatrixserverlib.RoomVersion]RoomVersionDescription{
|
||||||
// DefaultRoomVersion contains the room version that will, by
|
// DefaultRoomVersion contains the room version that will, by
|
||||||
// default, be used to create new rooms on this server.
|
// default, be used to create new rooms on this server.
|
||||||
func DefaultRoomVersion() gomatrixserverlib.RoomVersion {
|
func DefaultRoomVersion() gomatrixserverlib.RoomVersion {
|
||||||
return gomatrixserverlib.RoomVersionV2
|
return gomatrixserverlib.RoomVersionV4
|
||||||
}
|
}
|
||||||
|
|
||||||
// RoomVersions returns a map of all known room versions to this
|
// RoomVersions returns a map of all known room versions to this
|
||||||
|
|
Loading…
Reference in a new issue