Cleanup code in federationapi/routing (#571)
Signed-off-by: Anant Prakash <anantprakashjsr@gmail.com>
This commit is contained in:
parent
dc89e04e7d
commit
2c2200718a
@ -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)
|
||||
}
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user