diff options
author | Kegsay <kegan@matrix.org> | 2020-06-04 15:43:07 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-04 15:43:07 +0100 |
commit | 9834ac97db042b0c78fbd72652aa534129ca3afe (patch) | |
tree | 4fd862ffba61e47f94b2fcc5685a0502e21b3c70 /appservice/api | |
parent | d785ad82b996989381657292fbd2c28b9fbb7df6 (diff) |
Convert everything but serverkeyapi to inthttp (#1096)
* Convert roomserver to new inthttp format
* Convert eduserver to new inthttp format
* Convert appservice to new inthttp format
Diffstat (limited to 'appservice/api')
-rw-r--r-- | appservice/api/query.go | 57 |
1 files changed, 1 insertions, 56 deletions
diff --git a/appservice/api/query.go b/appservice/api/query.go index d36e138c..6fcb2089 100644 --- a/appservice/api/query.go +++ b/appservice/api/query.go @@ -20,16 +20,12 @@ package api import ( "context" "database/sql" - "errors" - "net/http" "github.com/matrix-org/dendrite/clientapi/auth/authtypes" "github.com/matrix-org/dendrite/clientapi/auth/storage/accounts" "github.com/matrix-org/gomatrixserverlib" "github.com/matrix-org/dendrite/internal" - internalHTTP "github.com/matrix-org/dendrite/internal/http" - opentracing "github.com/opentracing/opentracing-go" ) // RoomAliasExistsRequest is a request to an application service @@ -83,60 +79,9 @@ type AppServiceQueryAPI interface { ) error } -// AppServiceRoomAliasExistsPath is the HTTP path for the RoomAliasExists API -const AppServiceRoomAliasExistsPath = "/appservice/RoomAliasExists" - -// AppServiceUserIDExistsPath is the HTTP path for the UserIDExists API -const AppServiceUserIDExistsPath = "/appservice/UserIDExists" - -// httpAppServiceQueryAPI contains the URL to an appservice query API and a -// reference to a httpClient used to reach it -type httpAppServiceQueryAPI struct { - appserviceURL string - httpClient *http.Client -} - -// NewAppServiceQueryAPIHTTP creates a AppServiceQueryAPI implemented by talking -// to a HTTP POST API. -// If httpClient is nil an error is returned -func NewAppServiceQueryAPIHTTP( - appserviceURL string, - httpClient *http.Client, -) (AppServiceQueryAPI, error) { - if httpClient == nil { - return nil, errors.New("NewRoomserverAliasAPIHTTP: httpClient is <nil>") - } - return &httpAppServiceQueryAPI{appserviceURL, httpClient}, nil -} - -// RoomAliasExists implements AppServiceQueryAPI -func (h *httpAppServiceQueryAPI) RoomAliasExists( - ctx context.Context, - request *RoomAliasExistsRequest, - response *RoomAliasExistsResponse, -) error { - span, ctx := opentracing.StartSpanFromContext(ctx, "appserviceRoomAliasExists") - defer span.Finish() - - apiURL := h.appserviceURL + AppServiceRoomAliasExistsPath - return internalHTTP.PostJSON(ctx, span, h.httpClient, apiURL, request, response) -} - -// UserIDExists implements AppServiceQueryAPI -func (h *httpAppServiceQueryAPI) UserIDExists( - ctx context.Context, - request *UserIDExistsRequest, - response *UserIDExistsResponse, -) error { - span, ctx := opentracing.StartSpanFromContext(ctx, "appserviceUserIDExists") - defer span.Finish() - - apiURL := h.appserviceURL + AppServiceUserIDExistsPath - return internalHTTP.PostJSON(ctx, span, h.httpClient, apiURL, request, response) -} - // RetrieveUserProfile is a wrapper that queries both the local database and // application services for a given user's profile +// TODO: Remove this, it's called from federationapi and clientapi but is a pure function func RetrieveUserProfile( ctx context.Context, userID string, |