From ca1cb8fa9ce135ba4bf147343f53078b610b748a Mon Sep 17 00:00:00 2001 From: Prateek Sachan Date: Mon, 24 Feb 2020 02:09:29 +0530 Subject: [PATCH] Use hs_token when talking to appservice --- appservice/query/query.go | 8 ++++---- appservice/workers/transaction_scheduler.go | 2 +- go.mod | 2 ++ 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/appservice/query/query.go b/appservice/query/query.go index fde3ab09c..df4d830b3 100644 --- a/appservice/query/query.go +++ b/appservice/query/query.go @@ -180,10 +180,10 @@ func makeHTTPClient() *http.Client { } } -// SetupHTTP adds the AppServiceQueryPAI handlers to the http.ServeMux. This +// SetupHTTP adds the AppServiceQueryAPI handlers to the http.ServeMux. This // handles and muxes incoming api requests the to internal AppServiceQueryAPI. -func (a *AppServiceQueryAPI) SetupHTTP(servMux *http.ServeMux) { - servMux.Handle( +func (a *AppServiceQueryAPI) SetupHTTP(serveMux *http.ServeMux) { + serveMux.Handle( api.AppServiceRoomAliasExistsPath, common.MakeInternalAPI("appserviceRoomAliasExists", func(req *http.Request) util.JSONResponse { var request api.RoomAliasExistsRequest @@ -197,7 +197,7 @@ func (a *AppServiceQueryAPI) SetupHTTP(servMux *http.ServeMux) { return util.JSONResponse{Code: http.StatusOK, JSON: &response} }), ) - servMux.Handle( + serveMux.Handle( api.AppServiceUserIDExistsPath, common.MakeInternalAPI("appserviceUserIDExists", func(req *http.Request) util.JSONResponse { var request api.UserIDExistsRequest diff --git a/appservice/workers/transaction_scheduler.go b/appservice/workers/transaction_scheduler.go index faa1e4a96..1e0ddc33b 100644 --- a/appservice/workers/transaction_scheduler.go +++ b/appservice/workers/transaction_scheduler.go @@ -203,7 +203,7 @@ func send( transaction []byte, ) error { // POST a transaction to our AS - address := fmt.Sprintf("%s/transactions/%d", appservice.URL, txnID) + address := fmt.Sprintf("%s/transactions/%d?access_token=%s", appservice.URL, txnID, appservice.HSToken) resp, err := client.Post(address, "application/json", bytes.NewBuffer(transaction)) if err != nil { return err diff --git a/go.mod b/go.mod index 2d442cd0d..2fcfed420 100644 --- a/go.mod +++ b/go.mod @@ -19,6 +19,8 @@ require ( github.com/matrix-org/util v0.0.0-20171127121716-2e2df66af2f5 github.com/mattn/go-sqlite3 v2.0.2+incompatible github.com/miekg/dns v1.1.12 // indirect + github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect + github.com/modern-go/reflect2 v1.0.1 // indirect github.com/nfnt/resize v0.0.0-20160724205520-891127d8d1b5 github.com/opentracing/opentracing-go v1.0.2 github.com/pierrec/lz4 v2.4.1+incompatible // indirect