mirror of
https://github.com/hoernschen/dendrite.git
synced 2025-07-31 21:32:46 +00:00
Make federationapi use userapi (#1135)
Removes dependencies on account DB, device DB and ASAPI.
This commit is contained in:
parent
45011579eb
commit
1942928ee5
12 changed files with 102 additions and 66 deletions
|
@ -28,6 +28,7 @@ import (
|
|||
const (
|
||||
QueryProfilePath = "/userapi/queryProfile"
|
||||
QueryAccessTokenPath = "/userapi/queryAccessToken"
|
||||
QueryDevicesPath = "/userapi/queryDevices"
|
||||
)
|
||||
|
||||
// NewUserAPIClient creates a UserInternalAPI implemented by talking to a HTTP POST API.
|
||||
|
@ -73,3 +74,11 @@ func (h *httpUserInternalAPI) QueryAccessToken(
|
|||
apiURL := h.apiURL + QueryAccessTokenPath
|
||||
return httputil.PostJSON(ctx, span, h.httpClient, apiURL, request, response)
|
||||
}
|
||||
|
||||
func (h *httpUserInternalAPI) QueryDevices(ctx context.Context, req *api.QueryDevicesRequest, res *api.QueryDevicesResponse) error {
|
||||
span, ctx := opentracing.StartSpanFromContext(ctx, "QueryDevices")
|
||||
defer span.Finish()
|
||||
|
||||
apiURL := h.apiURL + QueryDevicesPath
|
||||
return httputil.PostJSON(ctx, span, h.httpClient, apiURL, req, res)
|
||||
}
|
||||
|
|
|
@ -51,4 +51,17 @@ func AddRoutes(internalAPIMux *mux.Router, s api.UserInternalAPI) {
|
|||
return util.JSONResponse{Code: http.StatusOK, JSON: &response}
|
||||
}),
|
||||
)
|
||||
internalAPIMux.Handle(QueryDevicesPath,
|
||||
httputil.MakeInternalAPI("queryDevices", func(req *http.Request) util.JSONResponse {
|
||||
request := api.QueryDevicesRequest{}
|
||||
response := api.QueryDevicesResponse{}
|
||||
if err := json.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||
return util.MessageResponse(http.StatusBadRequest, err.Error())
|
||||
}
|
||||
if err := s.QueryDevices(req.Context(), &request, &response); err != nil {
|
||||
return util.ErrorResponse(err)
|
||||
}
|
||||
return util.JSONResponse{Code: http.StatusOK, JSON: &response}
|
||||
}),
|
||||
)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue