aboutsummaryrefslogtreecommitdiff
path: root/federationapi/routing
diff options
context:
space:
mode:
authorNeil Alexander <neilalexander@users.noreply.github.com>2020-05-01 10:48:17 +0100
committerGitHub <noreply@github.com>2020-05-01 10:48:17 +0100
commite15f6676ac3f76ec2ef679c2df300d6a8e7e668f (patch)
tree0b82339939e8932d46e1ca2cf6024ab55dc7602f /federationapi/routing
parentebbfc125920beb321713e28a2a137d768406fa15 (diff)
Consolidation of roomserver APIs (#994)
* Consolidation of roomserver APIs * Comment out alias tests for now, they are broken * Wire AS API into roomserver again * Roomserver didn't take asAPI param before so return to that * Prevent roomserver asking AS API for alias info * Rename some files * Remove alias_test, incoherent tests and unwanted appservice integration * Remove FS API inject on syncapi component
Diffstat (limited to 'federationapi/routing')
-rw-r--r--federationapi/routing/backfill.go4
-rw-r--r--federationapi/routing/eventauth.go4
-rw-r--r--federationapi/routing/events.go10
-rw-r--r--federationapi/routing/join.go16
-rw-r--r--federationapi/routing/leave.go6
-rw-r--r--federationapi/routing/missingevents.go4
-rw-r--r--federationapi/routing/query.go4
-rw-r--r--federationapi/routing/routing.go29
-rw-r--r--federationapi/routing/send.go10
-rw-r--r--federationapi/routing/state.go14
-rw-r--r--federationapi/routing/threepid.go22
11 files changed, 61 insertions, 62 deletions
diff --git a/federationapi/routing/backfill.go b/federationapi/routing/backfill.go
index 6f49b9a8..651a4a2d 100644
--- a/federationapi/routing/backfill.go
+++ b/federationapi/routing/backfill.go
@@ -33,7 +33,7 @@ import (
func Backfill(
httpReq *http.Request,
request *gomatrixserverlib.FederationRequest,
- query api.RoomserverQueryAPI,
+ rsAPI api.RoomserverInternalAPI,
roomID string,
cfg *config.Dendrite,
) util.JSONResponse {
@@ -82,7 +82,7 @@ func Backfill(
}
// Query the roomserver.
- if err = query.QueryBackfill(httpReq.Context(), &req, &res); err != nil {
+ if err = rsAPI.QueryBackfill(httpReq.Context(), &req, &res); err != nil {
util.GetLogger(httpReq.Context()).WithError(err).Error("query.QueryBackfill failed")
return jsonerror.InternalServerError()
}
diff --git a/federationapi/routing/eventauth.go b/federationapi/routing/eventauth.go
index 003165c8..34eaad1c 100644
--- a/federationapi/routing/eventauth.go
+++ b/federationapi/routing/eventauth.go
@@ -25,13 +25,13 @@ import (
func GetEventAuth(
ctx context.Context,
request *gomatrixserverlib.FederationRequest,
- query api.RoomserverQueryAPI,
+ rsAPI api.RoomserverInternalAPI,
roomID string,
eventID string,
) util.JSONResponse {
// TODO: Optimisation: we shouldn't be querying all the room state
// that is in state.StateEvents - we just ignore it.
- state, err := getState(ctx, request, query, roomID, eventID)
+ state, err := getState(ctx, request, rsAPI, roomID, eventID)
if err != nil {
return *err
}
diff --git a/federationapi/routing/events.go b/federationapi/routing/events.go
index 03492db4..ced9e3d5 100644
--- a/federationapi/routing/events.go
+++ b/federationapi/routing/events.go
@@ -29,11 +29,11 @@ import (
func GetEvent(
ctx context.Context,
request *gomatrixserverlib.FederationRequest,
- query api.RoomserverQueryAPI,
+ rsAPI api.RoomserverInternalAPI,
eventID string,
origin gomatrixserverlib.ServerName,
) util.JSONResponse {
- event, err := getEvent(ctx, request, query, eventID)
+ event, err := getEvent(ctx, request, rsAPI, eventID)
if err != nil {
return *err
}
@@ -52,11 +52,11 @@ func GetEvent(
func getEvent(
ctx context.Context,
request *gomatrixserverlib.FederationRequest,
- query api.RoomserverQueryAPI,
+ rsAPI api.RoomserverInternalAPI,
eventID string,
) (*gomatrixserverlib.Event, *util.JSONResponse) {
var authResponse api.QueryServerAllowedToSeeEventResponse
- err := query.QueryServerAllowedToSeeEvent(
+ err := rsAPI.QueryServerAllowedToSeeEvent(
ctx,
&api.QueryServerAllowedToSeeEventRequest{
EventID: eventID,
@@ -75,7 +75,7 @@ func getEvent(
}
var eventsResponse api.QueryEventsByIDResponse
- err = query.QueryEventsByID(
+ err = rsAPI.QueryEventsByID(
ctx,
&api.QueryEventsByIDRequest{EventIDs: []string{eventID}},
&eventsResponse,
diff --git a/federationapi/routing/join.go b/federationapi/routing/join.go
index 0c899ab9..be5e988a 100644
--- a/federationapi/routing/join.go
+++ b/federationapi/routing/join.go
@@ -33,13 +33,13 @@ func MakeJoin(
httpReq *http.Request,
request *gomatrixserverlib.FederationRequest,
cfg *config.Dendrite,
- query api.RoomserverQueryAPI,
+ rsAPI api.RoomserverInternalAPI,
roomID, userID string,
remoteVersions []gomatrixserverlib.RoomVersion,
) util.JSONResponse {
verReq := api.QueryRoomVersionForRoomRequest{RoomID: roomID}
verRes := api.QueryRoomVersionForRoomResponse{}
- if err := query.QueryRoomVersionForRoom(httpReq.Context(), &verReq, &verRes); err != nil {
+ if err := rsAPI.QueryRoomVersionForRoom(httpReq.Context(), &verReq, &verRes); err != nil {
return util.JSONResponse{
Code: http.StatusInternalServerError,
JSON: jsonerror.InternalServerError(),
@@ -97,7 +97,7 @@ func MakeJoin(
queryRes := api.QueryLatestEventsAndStateResponse{
RoomVersion: verRes.RoomVersion,
}
- event, err := common.BuildEvent(httpReq.Context(), &builder, cfg, time.Now(), query, &queryRes)
+ event, err := common.BuildEvent(httpReq.Context(), &builder, cfg, time.Now(), rsAPI, &queryRes)
if err == common.ErrRoomNoExists {
return util.JSONResponse{
Code: http.StatusNotFound,
@@ -136,15 +136,15 @@ func SendJoin(
httpReq *http.Request,
request *gomatrixserverlib.FederationRequest,
cfg *config.Dendrite,
- query api.RoomserverQueryAPI,
+ rsAPI api.RoomserverInternalAPI,
producer *producers.RoomserverProducer,
keys gomatrixserverlib.KeyRing,
roomID, eventID string,
) util.JSONResponse {
verReq := api.QueryRoomVersionForRoomRequest{RoomID: roomID}
verRes := api.QueryRoomVersionForRoomResponse{}
- if err := query.QueryRoomVersionForRoom(httpReq.Context(), &verReq, &verRes); err != nil {
- util.GetLogger(httpReq.Context()).WithError(err).Error("query.QueryRoomVersionForRoom failed")
+ if err := rsAPI.QueryRoomVersionForRoom(httpReq.Context(), &verReq, &verRes); err != nil {
+ util.GetLogger(httpReq.Context()).WithError(err).Error("rsAPI.QueryRoomVersionForRoom failed")
return util.JSONResponse{
Code: http.StatusInternalServerError,
JSON: jsonerror.InternalServerError(),
@@ -216,14 +216,14 @@ func SendJoin(
// Fetch the state and auth chain. We do this before we send the events
// on, in case this fails.
var stateAndAuthChainResponse api.QueryStateAndAuthChainResponse
- err = query.QueryStateAndAuthChain(httpReq.Context(), &api.QueryStateAndAuthChainRequest{
+ err = rsAPI.QueryStateAndAuthChain(httpReq.Context(), &api.QueryStateAndAuthChainRequest{
PrevEventIDs: event.PrevEventIDs(),
AuthEventIDs: event.AuthEventIDs(),
RoomID: roomID,
ResolveState: true,
}, &stateAndAuthChainResponse)
if err != nil {
- util.GetLogger(httpReq.Context()).WithError(err).Error("query.QueryStateAndAuthChain failed")
+ util.GetLogger(httpReq.Context()).WithError(err).Error("rsAPI.QueryStateAndAuthChain failed")
return jsonerror.InternalServerError()
}
diff --git a/federationapi/routing/leave.go b/federationapi/routing/leave.go
index 6fc3b12e..1124bfa2 100644
--- a/federationapi/routing/leave.go
+++ b/federationapi/routing/leave.go
@@ -30,7 +30,7 @@ func MakeLeave(
httpReq *http.Request,
request *gomatrixserverlib.FederationRequest,
cfg *config.Dendrite,
- query api.RoomserverQueryAPI,
+ rsAPI api.RoomserverInternalAPI,
roomID, userID string,
) util.JSONResponse {
_, domain, err := gomatrixserverlib.SplitID('@', userID)
@@ -61,7 +61,7 @@ func MakeLeave(
}
var queryRes api.QueryLatestEventsAndStateResponse
- event, err := common.BuildEvent(httpReq.Context(), &builder, cfg, time.Now(), query, &queryRes)
+ event, err := common.BuildEvent(httpReq.Context(), &builder, cfg, time.Now(), rsAPI, &queryRes)
if err == common.ErrRoomNoExists {
return util.JSONResponse{
Code: http.StatusNotFound,
@@ -102,7 +102,7 @@ func SendLeave(
) util.JSONResponse {
verReq := api.QueryRoomVersionForRoomRequest{RoomID: roomID}
verRes := api.QueryRoomVersionForRoomResponse{}
- if err := producer.QueryAPI.QueryRoomVersionForRoom(httpReq.Context(), &verReq, &verRes); err != nil {
+ if err := producer.RsAPI.QueryRoomVersionForRoom(httpReq.Context(), &verReq, &verRes); err != nil {
return util.JSONResponse{
Code: http.StatusBadRequest,
JSON: jsonerror.UnsupportedRoomVersion(err.Error()),
diff --git a/federationapi/routing/missingevents.go b/federationapi/routing/missingevents.go
index 069bff3d..ae91c589 100644
--- a/federationapi/routing/missingevents.go
+++ b/federationapi/routing/missingevents.go
@@ -34,7 +34,7 @@ type getMissingEventRequest struct {
func GetMissingEvents(
httpReq *http.Request,
request *gomatrixserverlib.FederationRequest,
- query api.RoomserverQueryAPI,
+ rsAPI api.RoomserverInternalAPI,
roomID string,
) util.JSONResponse {
var gme getMissingEventRequest
@@ -46,7 +46,7 @@ func GetMissingEvents(
}
var eventsResponse api.QueryMissingEventsResponse
- if err := query.QueryMissingEvents(
+ if err := rsAPI.QueryMissingEvents(
httpReq.Context(), &api.QueryMissingEventsRequest{
EarliestEvents: gme.EarliestEvents,
LatestEvents: gme.LatestEvents,
diff --git a/federationapi/routing/query.go b/federationapi/routing/query.go
index 13c92451..c58690c6 100644
--- a/federationapi/routing/query.go
+++ b/federationapi/routing/query.go
@@ -32,7 +32,7 @@ func RoomAliasToID(
httpReq *http.Request,
federation *gomatrixserverlib.FederationClient,
cfg *config.Dendrite,
- aliasAPI roomserverAPI.RoomserverAliasAPI,
+ rsAPI roomserverAPI.RoomserverInternalAPI,
senderAPI federationSenderAPI.FederationSenderInternalAPI,
) util.JSONResponse {
roomAlias := httpReq.FormValue("room_alias")
@@ -55,7 +55,7 @@ func RoomAliasToID(
if domain == cfg.Matrix.ServerName {
queryReq := roomserverAPI.GetRoomIDForAliasRequest{Alias: roomAlias}
var queryRes roomserverAPI.GetRoomIDForAliasResponse
- if err = aliasAPI.GetRoomIDForAlias(httpReq.Context(), &queryReq, &queryRes); err != nil {
+ if err = rsAPI.GetRoomIDForAlias(httpReq.Context(), &queryReq, &queryRes); err != nil {
util.GetLogger(httpReq.Context()).WithError(err).Error("aliasAPI.GetRoomIDForAlias failed")
return jsonerror.InternalServerError()
}
diff --git a/federationapi/routing/routing.go b/federationapi/routing/routing.go
index e0f842f1..a5b8ce24 100644
--- a/federationapi/routing/routing.go
+++ b/federationapi/routing/routing.go
@@ -44,8 +44,7 @@ const (
func Setup(
apiMux *mux.Router,
cfg *config.Dendrite,
- query roomserverAPI.RoomserverQueryAPI,
- aliasAPI roomserverAPI.RoomserverAliasAPI,
+ rsAPI roomserverAPI.RoomserverInternalAPI,
asAPI appserviceAPI.AppServiceQueryAPI,
producer *producers.RoomserverProducer,
eduProducer *producers.EDUServerProducer,
@@ -80,7 +79,7 @@ func Setup(
}
return Send(
httpReq, request, gomatrixserverlib.TransactionID(vars["txnID"]),
- cfg, query, producer, eduProducer, keys, federation,
+ cfg, rsAPI, producer, eduProducer, keys, federation,
)
},
)).Methods(http.MethodPut, http.MethodOptions)
@@ -101,7 +100,7 @@ func Setup(
v1fedmux.Handle("/3pid/onbind", common.MakeExternalAPI("3pid_onbind",
func(req *http.Request) util.JSONResponse {
- return CreateInvitesFrom3PIDInvites(req, query, asAPI, cfg, producer, federation, accountDB)
+ return CreateInvitesFrom3PIDInvites(req, rsAPI, asAPI, cfg, producer, federation, accountDB)
},
)).Methods(http.MethodPost, http.MethodOptions)
@@ -113,7 +112,7 @@ func Setup(
return util.ErrorResponse(err)
}
return ExchangeThirdPartyInvite(
- httpReq, request, vars["roomID"], query, cfg, federation, producer,
+ httpReq, request, vars["roomID"], rsAPI, cfg, federation, producer,
)
},
)).Methods(http.MethodPut, http.MethodOptions)
@@ -126,7 +125,7 @@ func Setup(
return util.ErrorResponse(err)
}
return GetEvent(
- httpReq.Context(), request, query, vars["eventID"], cfg.Matrix.ServerName,
+ httpReq.Context(), request, rsAPI, vars["eventID"], cfg.Matrix.ServerName,
)
},
)).Methods(http.MethodGet)
@@ -139,7 +138,7 @@ func Setup(
return util.ErrorResponse(err)
}
return GetState(
- httpReq.Context(), request, query, vars["roomID"],
+ httpReq.Context(), request, rsAPI, vars["roomID"],
)
},
)).Methods(http.MethodGet)
@@ -152,7 +151,7 @@ func Setup(
return util.ErrorResponse(err)
}
return GetStateIDs(
- httpReq.Context(), request, query, vars["roomID"],
+ httpReq.Context(), request, rsAPI, vars["roomID"],
)
},
)).Methods(http.MethodGet)
@@ -162,7 +161,7 @@ func Setup(
func(httpReq *http.Request, request *gomatrixserverlib.FederationRequest) util.JSONResponse {
vars := mux.Vars(httpReq)
return GetEventAuth(
- httpReq.Context(), request, query, vars["roomID"], vars["eventID"],
+ httpReq.Context(), request, rsAPI, vars["roomID"], vars["eventID"],
)
},
)).Methods(http.MethodGet)
@@ -171,7 +170,7 @@ func Setup(
"federation_query_room_alias", cfg.Matrix.ServerName, keys,
func(httpReq *http.Request, request *gomatrixserverlib.FederationRequest) util.JSONResponse {
return RoomAliasToID(
- httpReq, federation, cfg, aliasAPI, federationSenderAPI,
+ httpReq, federation, cfg, rsAPI, federationSenderAPI,
)
},
)).Methods(http.MethodGet)
@@ -222,7 +221,7 @@ func Setup(
remoteVersions = append(remoteVersions, gomatrixserverlib.RoomVersionV1)
}
return MakeJoin(
- httpReq, request, cfg, query, roomID, eventID, remoteVersions,
+ httpReq, request, cfg, rsAPI, roomID, eventID, remoteVersions,
)
},
)).Methods(http.MethodGet)
@@ -237,7 +236,7 @@ func Setup(
roomID := vars["roomID"]
eventID := vars["eventID"]
return SendJoin(
- httpReq, request, cfg, query, producer, keys, roomID, eventID,
+ httpReq, request, cfg, rsAPI, producer, keys, roomID, eventID,
)
},
)).Methods(http.MethodPut)
@@ -252,7 +251,7 @@ func Setup(
roomID := vars["roomID"]
eventID := vars["eventID"]
return MakeLeave(
- httpReq, request, cfg, query, roomID, eventID,
+ httpReq, request, cfg, rsAPI, roomID, eventID,
)
},
)).Methods(http.MethodGet)
@@ -286,7 +285,7 @@ func Setup(
if err != nil {
return util.ErrorResponse(err)
}
- return GetMissingEvents(httpReq, request, query, vars["roomID"])
+ return GetMissingEvents(httpReq, request, rsAPI, vars["roomID"])
},
)).Methods(http.MethodPost)
@@ -297,7 +296,7 @@ func Setup(
if err != nil {
return util.ErrorResponse(err)
}
- return Backfill(httpReq, request, query, vars["roomID"], cfg)
+ return Backfill(httpReq, request, rsAPI, vars["roomID"], cfg)
},
)).Methods(http.MethodGet)
}
diff --git a/federationapi/routing/send.go b/federationapi/routing/send.go
index 5a9766f8..88411b81 100644
--- a/federationapi/routing/send.go
+++ b/federationapi/routing/send.go
@@ -34,7 +34,7 @@ func Send(
request *gomatrixserverlib.FederationRequest,
txnID gomatrixserverlib.TransactionID,
cfg *config.Dendrite,
- query api.RoomserverQueryAPI,
+ rsAPI api.RoomserverInternalAPI,
producer *producers.RoomserverProducer,
eduProducer *producers.EDUServerProducer,
keys gomatrixserverlib.KeyRing,
@@ -42,7 +42,7 @@ func Send(
) util.JSONResponse {
t := txnReq{
context: httpReq.Context(),
- query: query,
+ rsAPI: rsAPI,
producer: producer,
eduProducer: eduProducer,
keys: keys,
@@ -99,7 +99,7 @@ func Send(
type txnReq struct {
gomatrixserverlib.Transaction
context context.Context
- query api.RoomserverQueryAPI
+ rsAPI api.RoomserverInternalAPI
producer *producers.RoomserverProducer
eduProducer *producers.EDUServerProducer
keys gomatrixserverlib.KeyRing
@@ -120,7 +120,7 @@ func (t *txnReq) processTransaction() (*gomatrixserverlib.RespSend, error) {
}
verReq := api.QueryRoomVersionForRoomRequest{RoomID: header.RoomID}
verRes := api.QueryRoomVersionForRoomResponse{}
- if err := t.query.QueryRoomVersionForRoom(t.context, &verReq, &verRes); err != nil {
+ if err := t.rsAPI.QueryRoomVersionForRoom(t.context, &verReq, &verRes); err != nil {
util.GetLogger(t.context).WithError(err).Warn("Transaction: Failed to query room version for room", verReq.RoomID)
return nil, roomNotFoundError{verReq.RoomID}
}
@@ -228,7 +228,7 @@ func (t *txnReq) processEvent(e gomatrixserverlib.Event) error {
StateToFetch: needed.Tuples(),
}
var stateResp api.QueryStateAfterEventsResponse
- if err := t.query.QueryStateAfterEvents(t.context, &stateReq, &stateResp); err != nil {
+ if err := t.rsAPI.QueryStateAfterEvents(t.context, &stateReq, &stateResp); err != nil {
return err
}
diff --git a/federationapi/routing/state.go b/federationapi/routing/state.go
index 548598dd..f90c494c 100644
--- a/federationapi/routing/state.go
+++ b/federationapi/routing/state.go
@@ -27,7 +27,7 @@ import (
func GetState(
ctx context.Context,
request *gomatrixserverlib.FederationRequest,
- query api.RoomserverQueryAPI,
+ rsAPI api.RoomserverInternalAPI,
roomID string,
) util.JSONResponse {
eventID, err := parseEventIDParam(request)
@@ -35,7 +35,7 @@ func GetState(
return *err
}
- state, err := getState(ctx, request, query, roomID, eventID)
+ state, err := getState(ctx, request, rsAPI, roomID, eventID)
if err != nil {
return *err
}
@@ -47,7 +47,7 @@ func GetState(
func GetStateIDs(
ctx context.Context,
request *gomatrixserverlib.FederationRequest,
- query api.RoomserverQueryAPI,
+ rsAPI api.RoomserverInternalAPI,
roomID string,
) util.JSONResponse {
eventID, err := parseEventIDParam(request)
@@ -55,7 +55,7 @@ func GetStateIDs(
return *err
}
- state, err := getState(ctx, request, query, roomID, eventID)
+ state, err := getState(ctx, request, rsAPI, roomID, eventID)
if err != nil {
return *err
}
@@ -94,11 +94,11 @@ func parseEventIDParam(
func getState(
ctx context.Context,
request *gomatrixserverlib.FederationRequest,
- query api.RoomserverQueryAPI,
+ rsAPI api.RoomserverInternalAPI,
roomID string,
eventID string,
) (*gomatrixserverlib.RespState, *util.JSONResponse) {
- event, resErr := getEvent(ctx, request, query, eventID)
+ event, resErr := getEvent(ctx, request, rsAPI, eventID)
if resErr != nil {
return nil, resErr
}
@@ -110,7 +110,7 @@ func getState(
authEventIDs := getIDsFromEventRef(event.AuthEvents())
var response api.QueryStateAndAuthChainResponse
- err := query.QueryStateAndAuthChain(
+ err := rsAPI.QueryStateAndAuthChain(
ctx,
&api.QueryStateAndAuthChainRequest{
RoomID: roomID,
diff --git a/federationapi/routing/threepid.go b/federationapi/routing/threepid.go
index f93d934e..3c1d09e1 100644
--- a/federationapi/routing/threepid.go
+++ b/federationapi/routing/threepid.go
@@ -58,7 +58,7 @@ var (
// CreateInvitesFrom3PIDInvites implements POST /_matrix/federation/v1/3pid/onbind
func CreateInvitesFrom3PIDInvites(
- req *http.Request, queryAPI roomserverAPI.RoomserverQueryAPI,
+ req *http.Request, rsAPI roomserverAPI.RoomserverInternalAPI,
asAPI appserviceAPI.AppServiceQueryAPI, cfg *config.Dendrite,
producer *producers.RoomserverProducer, federation *gomatrixserverlib.FederationClient,
accountDB accounts.Database,
@@ -72,7 +72,7 @@ func CreateInvitesFrom3PIDInvites(
for _, inv := range body.Invites {
verReq := api.QueryRoomVersionForRoomRequest{RoomID: inv.RoomID}
verRes := api.QueryRoomVersionForRoomResponse{}
- if err := queryAPI.QueryRoomVersionForRoom(req.Context(), &verReq, &verRes); err != nil {
+ if err := rsAPI.QueryRoomVersionForRoom(req.Context(), &verReq, &verRes); err != nil {
return util.JSONResponse{
Code: http.StatusBadRequest,
JSON: jsonerror.UnsupportedRoomVersion(err.Error()),
@@ -80,7 +80,7 @@ func CreateInvitesFrom3PIDInvites(
}
event, err := createInviteFrom3PIDInvite(
- req.Context(), queryAPI, asAPI, cfg, inv, federation, accountDB,
+ req.Context(), rsAPI, asAPI, cfg, inv, federation, accountDB,
)
if err != nil {
util.GetLogger(req.Context()).WithError(err).Error("createInviteFrom3PIDInvite failed")
@@ -108,7 +108,7 @@ func ExchangeThirdPartyInvite(
httpReq *http.Request,
request *gomatrixserverlib.FederationRequest,
roomID string,
- queryAPI roomserverAPI.RoomserverQueryAPI,
+ rsAPI roomserverAPI.RoomserverInternalAPI,
cfg *config.Dendrite,
federation *gomatrixserverlib.FederationClient,
producer *producers.RoomserverProducer,
@@ -148,7 +148,7 @@ func ExchangeThirdPartyInvite(
verReq := api.QueryRoomVersionForRoomRequest{RoomID: roomID}
verRes := api.QueryRoomVersionForRoomResponse{}
- if err = queryAPI.QueryRoomVersionForRoom(httpReq.Context(), &verReq, &verRes); err != nil {
+ if err = rsAPI.QueryRoomVersionForRoom(httpReq.Context(), &verReq, &verRes); err != nil {
return util.JSONResponse{
Code: http.StatusBadRequest,
JSON: jsonerror.UnsupportedRoomVersion(err.Error()),
@@ -156,7 +156,7 @@ func ExchangeThirdPartyInvite(
}
// Auth and build the event from what the remote server sent us
- event, err := buildMembershipEvent(httpReq.Context(), &builder, queryAPI, cfg)
+ event, err := buildMembershipEvent(httpReq.Context(), &builder, rsAPI, cfg)
if err == errNotInRoom {
return util.JSONResponse{
Code: http.StatusNotFound,
@@ -199,14 +199,14 @@ func ExchangeThirdPartyInvite(
// Returns an error if there was a problem building the event or fetching the
// necessary data to do so.
func createInviteFrom3PIDInvite(
- ctx context.Context, queryAPI roomserverAPI.RoomserverQueryAPI,
+ ctx context.Context, rsAPI roomserverAPI.RoomserverInternalAPI,
asAPI appserviceAPI.AppServiceQueryAPI, cfg *config.Dendrite,
inv invite, federation *gomatrixserverlib.FederationClient,
accountDB accounts.Database,
) (*gomatrixserverlib.Event, error) {
verReq := api.QueryRoomVersionForRoomRequest{RoomID: inv.RoomID}
verRes := api.QueryRoomVersionForRoomResponse{}
- if err := queryAPI.QueryRoomVersionForRoom(ctx, &verReq, &verRes); err != nil {
+ if err := rsAPI.QueryRoomVersionForRoom(ctx, &verReq, &verRes); err != nil {
return nil, err
}
@@ -245,7 +245,7 @@ func createInviteFrom3PIDInvite(
return nil, err
}
- event, err := buildMembershipEvent(ctx, builder, queryAPI, cfg)
+ event, err := buildMembershipEvent(ctx, builder, rsAPI, cfg)
if err == errNotInRoom {
return nil, sendToRemoteServer(ctx, inv, federation, cfg, *builder)
}
@@ -263,7 +263,7 @@ func createInviteFrom3PIDInvite(
// Returns an error if something failed during the process.
func buildMembershipEvent(
ctx context.Context,
- builder *gomatrixserverlib.EventBuilder, queryAPI roomserverAPI.RoomserverQueryAPI,
+ builder *gomatrixserverlib.EventBuilder, rsAPI roomserverAPI.RoomserverInternalAPI,
cfg *config.Dendrite,
) (*gomatrixserverlib.Event, error) {
eventsNeeded, err := gomatrixserverlib.StateNeededForEventBuilder(builder)
@@ -281,7 +281,7 @@ func buildMembershipEvent(
StateToFetch: eventsNeeded.Tuples(),
}
var queryRes roomserverAPI.QueryLatestEventsAndStateResponse
- if err = queryAPI.QueryLatestEventsAndState(ctx, &queryReq, &queryRes); err != nil {
+ if err = rsAPI.QueryLatestEventsAndState(ctx, &queryReq, &queryRes); err != nil {
return nil, err
}