aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnant Prakash <anantprakashjsr@gmail.com>2018-08-06 18:37:29 +0530
committerGitHub <noreply@github.com>2018-08-06 18:37:29 +0530
commit2c2200718a4afcaee712bdeadb69f33ff2522a12 (patch)
treecd9e68e158839c2d8ec6c4ca6b54a503ef137c0e
parentdc89e04e7dcfcae5ecfba4db3f6242c8e02e0438 (diff)
Cleanup code in federationapi/routing (#571)
Signed-off-by: Anant Prakash <anantprakashjsr@gmail.com>
-rw-r--r--src/github.com/matrix-org/dendrite/federationapi/routing/join.go10
-rw-r--r--src/github.com/matrix-org/dendrite/federationapi/routing/routing.go9
-rw-r--r--src/github.com/matrix-org/dendrite/federationapi/routing/state.go8
3 files changed, 8 insertions, 19 deletions
diff --git a/src/github.com/matrix-org/dendrite/federationapi/routing/join.go b/src/github.com/matrix-org/dendrite/federationapi/routing/join.go
index cb285c2e..6df049bd 100644
--- a/src/github.com/matrix-org/dendrite/federationapi/routing/join.go
+++ b/src/github.com/matrix-org/dendrite/federationapi/routing/join.go
@@ -15,7 +15,6 @@
package routing
import (
- "context"
"encoding/json"
"net/http"
@@ -95,7 +94,6 @@ func MakeJoin(
// SendJoin implements the /send_join API
func SendJoin(
- ctx context.Context,
httpReq *http.Request,
request *gomatrixserverlib.FederationRequest,
cfg config.Dendrite,
@@ -142,7 +140,7 @@ func SendJoin(
Message: event.Redact().JSON(),
AtTS: event.OriginServerTS(),
}}
- verifyResults, err := keys.VerifyJSONs(ctx, verifyRequests)
+ verifyResults, err := keys.VerifyJSONs(httpReq.Context(), verifyRequests)
if err != nil {
return httputil.LogThenError(httpReq, err)
}
@@ -156,7 +154,7 @@ func SendJoin(
// Fetch the state and auth chain. We do this before we send the events
// on, in case this fails.
var stateAndAuthChainRepsonse api.QueryStateAndAuthChainResponse
- err = query.QueryStateAndAuthChain(ctx, &api.QueryStateAndAuthChainRequest{
+ err = query.QueryStateAndAuthChain(httpReq.Context(), &api.QueryStateAndAuthChainRequest{
PrevEventIDs: event.PrevEventIDs(),
AuthEventIDs: event.AuthEventIDs(),
RoomID: roomID,
@@ -168,7 +166,9 @@ func SendJoin(
// Send the events to the room server.
// We are responsible for notifying other servers that the user has joined
// the room, so set SendAsServer to cfg.Matrix.ServerName
- _, err = producer.SendEvents(ctx, []gomatrixserverlib.Event{event}, cfg.Matrix.ServerName, nil)
+ _, err = producer.SendEvents(
+ httpReq.Context(), []gomatrixserverlib.Event{event}, cfg.Matrix.ServerName, nil,
+ )
if err != nil {
return httputil.LogThenError(httpReq, err)
}
diff --git a/src/github.com/matrix-org/dendrite/federationapi/routing/routing.go b/src/github.com/matrix-org/dendrite/federationapi/routing/routing.go
index b04a270a..d25d4424 100644
--- a/src/github.com/matrix-org/dendrite/federationapi/routing/routing.go
+++ b/src/github.com/matrix-org/dendrite/federationapi/routing/routing.go
@@ -16,7 +16,6 @@ package routing
import (
"net/http"
- "time"
"github.com/gorilla/mux"
"github.com/matrix-org/dendrite/clientapi/auth/storage/accounts"
@@ -113,8 +112,7 @@ func Setup(
func(httpReq *http.Request, request *gomatrixserverlib.FederationRequest) util.JSONResponse {
vars := mux.Vars(httpReq)
return GetState(
- httpReq.Context(), request, cfg, query, time.Now(),
- keys, vars["roomID"],
+ httpReq.Context(), request, query, vars["roomID"],
)
},
)).Methods(http.MethodGet)
@@ -124,8 +122,7 @@ func Setup(
func(httpReq *http.Request, request *gomatrixserverlib.FederationRequest) util.JSONResponse {
vars := mux.Vars(httpReq)
return GetStateIDs(
- httpReq.Context(), request, cfg, query, time.Now(),
- keys, vars["roomID"],
+ httpReq.Context(), request, query, vars["roomID"],
)
},
)).Methods(http.MethodGet)
@@ -177,7 +174,7 @@ func Setup(
roomID := vars["roomID"]
userID := vars["userID"]
return SendJoin(
- httpReq.Context(), httpReq, request, cfg, query, producer, keys, roomID, userID,
+ httpReq, request, cfg, query, producer, keys, roomID, userID,
)
},
)).Methods(http.MethodPut)
diff --git a/src/github.com/matrix-org/dendrite/federationapi/routing/state.go b/src/github.com/matrix-org/dendrite/federationapi/routing/state.go
index 40db82b6..130f8a4f 100644
--- a/src/github.com/matrix-org/dendrite/federationapi/routing/state.go
+++ b/src/github.com/matrix-org/dendrite/federationapi/routing/state.go
@@ -16,10 +16,8 @@ import (
"context"
"net/http"
"net/url"
- "time"
"github.com/matrix-org/dendrite/clientapi/jsonerror"
- "github.com/matrix-org/dendrite/common/config"
"github.com/matrix-org/dendrite/roomserver/api"
"github.com/matrix-org/gomatrixserverlib"
"github.com/matrix-org/util"
@@ -29,10 +27,7 @@ import (
func GetState(
ctx context.Context,
request *gomatrixserverlib.FederationRequest,
- _ config.Dendrite,
query api.RoomserverQueryAPI,
- _ time.Time,
- _ gomatrixserverlib.KeyRing,
roomID string,
) util.JSONResponse {
eventID, err := parseEventIDParam(request)
@@ -52,10 +47,7 @@ func GetState(
func GetStateIDs(
ctx context.Context,
request *gomatrixserverlib.FederationRequest,
- _ config.Dendrite,
query api.RoomserverQueryAPI,
- _ time.Time,
- _ gomatrixserverlib.KeyRing,
roomID string,
) util.JSONResponse {
eventID, err := parseEventIDParam(request)