mirror of
https://github.com/hoernschen/dendrite.git
synced 2025-08-02 14:12:47 +00:00
Add query functions in the federation API
This commit is contained in:
parent
61406a6747
commit
739acc1291
4 changed files with 256 additions and 0 deletions
|
@ -17,6 +17,9 @@ import (
|
|||
const (
|
||||
FederationAPIQueryJoinedHostServerNamesInRoomPath = "/federationapi/queryJoinedHostServerNamesInRoom"
|
||||
FederationAPIQueryServerKeysPath = "/federationapi/queryServerKeys"
|
||||
FederationAPIQueryEventAuthFromFederationPath = "/federationapi/queryEventAuthFromFederation"
|
||||
FederationAPIQueryStateIDsFromFederationPath = "/federationapi/queryStateIDsFromFederation"
|
||||
FederationAPIQueryStateFromFederationPath = "/federationapi/queryStateFromFederation"
|
||||
|
||||
FederationAPIPerformDirectoryLookupRequestPath = "/federationapi/performDirectoryLookup"
|
||||
FederationAPIPerformJoinRequestPath = "/federationapi/performJoinRequest"
|
||||
|
@ -120,6 +123,45 @@ func (h *httpFederationInternalAPI) QueryJoinedHostServerNamesInRoom(
|
|||
return httputil.PostJSON(ctx, span, h.httpClient, apiURL, request, response)
|
||||
}
|
||||
|
||||
// QueryEventAuthFromFederation implements FederationInternalAPI
|
||||
func (h *httpFederationInternalAPI) QueryEventAuthFromFederation(
|
||||
ctx context.Context,
|
||||
request *api.QueryEventAuthFromFederationRequest,
|
||||
response *api.QueryEventAuthFromFederationResponse,
|
||||
) error {
|
||||
span, ctx := opentracing.StartSpanFromContext(ctx, "QueryEventAuthFromFederation")
|
||||
defer span.Finish()
|
||||
|
||||
apiURL := h.federationAPIURL + FederationAPIQueryEventAuthFromFederationPath
|
||||
return httputil.PostJSON(ctx, span, h.httpClient, apiURL, request, response)
|
||||
}
|
||||
|
||||
// QueryStateIDsFromFederation implements FederationInternalAPI
|
||||
func (h *httpFederationInternalAPI) QueryStateIDsFromFederation(
|
||||
ctx context.Context,
|
||||
request *api.QueryStateIDsFromFederationRequest,
|
||||
response *api.QueryStateIDsFromFederationResponse,
|
||||
) error {
|
||||
span, ctx := opentracing.StartSpanFromContext(ctx, "QueryStateIDsFromFederation")
|
||||
defer span.Finish()
|
||||
|
||||
apiURL := h.federationAPIURL + FederationAPIQueryStateIDsFromFederationPath
|
||||
return httputil.PostJSON(ctx, span, h.httpClient, apiURL, request, response)
|
||||
}
|
||||
|
||||
// QueryEventAuthFromFederation implements FederationInternalAPI
|
||||
func (h *httpFederationInternalAPI) QueryStateFromFederation(
|
||||
ctx context.Context,
|
||||
request *api.QueryStateFromFederationRequest,
|
||||
response *api.QueryStateFromFederationResponse,
|
||||
) error {
|
||||
span, ctx := opentracing.StartSpanFromContext(ctx, "QueryStateFromFederation")
|
||||
defer span.Finish()
|
||||
|
||||
apiURL := h.federationAPIURL + FederationAPIQueryStateFromFederationPath
|
||||
return httputil.PostJSON(ctx, span, h.httpClient, apiURL, request, response)
|
||||
}
|
||||
|
||||
// Handle an instruction to make_join & send_join with a remote server.
|
||||
func (h *httpFederationInternalAPI) PerformJoin(
|
||||
ctx context.Context,
|
||||
|
|
|
@ -27,6 +27,48 @@ func AddRoutes(intAPI api.FederationInternalAPI, internalAPIMux *mux.Router) {
|
|||
return util.JSONResponse{Code: http.StatusOK, JSON: &response}
|
||||
}),
|
||||
)
|
||||
internalAPIMux.Handle(
|
||||
FederationAPIQueryEventAuthFromFederationPath,
|
||||
httputil.MakeInternalAPI("QueryEventAuthFromFederation", func(req *http.Request) util.JSONResponse {
|
||||
var request api.QueryEventAuthFromFederationRequest
|
||||
var response api.QueryEventAuthFromFederationResponse
|
||||
if err := json.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||
return util.ErrorResponse(err)
|
||||
}
|
||||
if err := intAPI.QueryEventAuthFromFederation(req.Context(), &request, &response); err != nil {
|
||||
return util.ErrorResponse(err)
|
||||
}
|
||||
return util.JSONResponse{Code: http.StatusOK, JSON: &response}
|
||||
}),
|
||||
)
|
||||
internalAPIMux.Handle(
|
||||
FederationAPIQueryStateIDsFromFederationPath,
|
||||
httputil.MakeInternalAPI("QueryStateIDsFromFederation", func(req *http.Request) util.JSONResponse {
|
||||
var request api.QueryStateIDsFromFederationRequest
|
||||
var response api.QueryStateIDsFromFederationResponse
|
||||
if err := json.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||
return util.ErrorResponse(err)
|
||||
}
|
||||
if err := intAPI.QueryStateIDsFromFederation(req.Context(), &request, &response); err != nil {
|
||||
return util.ErrorResponse(err)
|
||||
}
|
||||
return util.JSONResponse{Code: http.StatusOK, JSON: &response}
|
||||
}),
|
||||
)
|
||||
internalAPIMux.Handle(
|
||||
FederationAPIQueryStateFromFederationPath,
|
||||
httputil.MakeInternalAPI("QueryStateFromFederation", func(req *http.Request) util.JSONResponse {
|
||||
var request api.QueryStateFromFederationRequest
|
||||
var response api.QueryStateFromFederationResponse
|
||||
if err := json.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||
return util.ErrorResponse(err)
|
||||
}
|
||||
if err := intAPI.QueryStateFromFederation(req.Context(), &request, &response); err != nil {
|
||||
return util.ErrorResponse(err)
|
||||
}
|
||||
return util.JSONResponse{Code: http.StatusOK, JSON: &response}
|
||||
}),
|
||||
)
|
||||
internalAPIMux.Handle(
|
||||
FederationAPIPerformJoinRequestPath,
|
||||
httputil.MakeInternalAPI("PerformJoinRequest", func(req *http.Request) util.JSONResponse {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue