aboutsummaryrefslogtreecommitdiff
path: root/clientapi
diff options
context:
space:
mode:
authorKegsay <kegan@matrix.org>2020-09-04 12:30:56 +0100
committerGitHub <noreply@github.com>2020-09-04 12:30:56 +0100
commit81688d6bde5e544d11691e5b137eb444a35c9d32 (patch)
treefc7403b008742c3ccfb1b75d666a9716a6700d24 /clientapi
parent67cc8619d3c655beb91387cd82ecccd50b0d8f48 (diff)
Remove QueryCurrentState from current-state-server (#1395)
Diffstat (limited to 'clientapi')
-rw-r--r--clientapi/routing/directory.go2
-rw-r--r--clientapi/routing/membership.go10
-rw-r--r--clientapi/routing/redaction.go7
-rw-r--r--clientapi/routing/routing.go8
-rw-r--r--clientapi/routing/sendtyping.go6
5 files changed, 15 insertions, 18 deletions
diff --git a/clientapi/routing/directory.go b/clientapi/routing/directory.go
index 62f295fe..13fbfe7c 100644
--- a/clientapi/routing/directory.go
+++ b/clientapi/routing/directory.go
@@ -273,7 +273,7 @@ func SetVisibility(
req *http.Request, stateAPI currentstateAPI.CurrentStateInternalAPI, rsAPI roomserverAPI.RoomserverInternalAPI, dev *userapi.Device,
roomID string,
) util.JSONResponse {
- resErr := checkMemberInRoom(req.Context(), stateAPI, dev.UserID, roomID)
+ resErr := checkMemberInRoom(req.Context(), rsAPI, dev.UserID, roomID)
if resErr != nil {
return *resErr
}
diff --git a/clientapi/routing/membership.go b/clientapi/routing/membership.go
index 202662ab..88cb2364 100644
--- a/clientapi/routing/membership.go
+++ b/clientapi/routing/membership.go
@@ -25,7 +25,6 @@ import (
"github.com/matrix-org/dendrite/clientapi/httputil"
"github.com/matrix-org/dendrite/clientapi/jsonerror"
"github.com/matrix-org/dendrite/clientapi/threepid"
- currentstateAPI "github.com/matrix-org/dendrite/currentstateserver/api"
"github.com/matrix-org/dendrite/internal/config"
"github.com/matrix-org/dendrite/internal/eventutil"
"github.com/matrix-org/dendrite/roomserver/api"
@@ -95,7 +94,6 @@ func SendKick(
req *http.Request, accountDB accounts.Database, device *userapi.Device,
roomID string, cfg *config.ClientAPI,
rsAPI roomserverAPI.RoomserverInternalAPI, asAPI appserviceAPI.AppServiceQueryAPI,
- stateAPI currentstateAPI.CurrentStateInternalAPI,
) util.JSONResponse {
body, evTime, roomVer, reqErr := extractRequestData(req, roomID, rsAPI)
if reqErr != nil {
@@ -108,7 +106,7 @@ func SendKick(
}
}
- errRes := checkMemberInRoom(req.Context(), stateAPI, device.UserID, roomID)
+ errRes := checkMemberInRoom(req.Context(), rsAPI, device.UserID, roomID)
if errRes != nil {
return *errRes
}
@@ -372,13 +370,13 @@ func checkAndProcessThreepid(
return
}
-func checkMemberInRoom(ctx context.Context, stateAPI currentstateAPI.CurrentStateInternalAPI, userID, roomID string) *util.JSONResponse {
+func checkMemberInRoom(ctx context.Context, rsAPI api.RoomserverInternalAPI, userID, roomID string) *util.JSONResponse {
tuple := gomatrixserverlib.StateKeyTuple{
EventType: gomatrixserverlib.MRoomMember,
StateKey: userID,
}
- var membershipRes currentstateAPI.QueryCurrentStateResponse
- err := stateAPI.QueryCurrentState(ctx, &currentstateAPI.QueryCurrentStateRequest{
+ var membershipRes api.QueryCurrentStateResponse
+ err := rsAPI.QueryCurrentState(ctx, &api.QueryCurrentStateRequest{
RoomID: roomID,
StateTuples: []gomatrixserverlib.StateKeyTuple{tuple},
}, &membershipRes)
diff --git a/clientapi/routing/redaction.go b/clientapi/routing/redaction.go
index 178bfafc..9701685e 100644
--- a/clientapi/routing/redaction.go
+++ b/clientapi/routing/redaction.go
@@ -21,7 +21,6 @@ import (
"github.com/matrix-org/dendrite/clientapi/httputil"
"github.com/matrix-org/dendrite/clientapi/jsonerror"
- currentstateAPI "github.com/matrix-org/dendrite/currentstateserver/api"
"github.com/matrix-org/dendrite/internal/config"
"github.com/matrix-org/dendrite/internal/eventutil"
"github.com/matrix-org/dendrite/roomserver/api"
@@ -41,9 +40,9 @@ type redactionResponse struct {
func SendRedaction(
req *http.Request, device *userapi.Device, roomID, eventID string, cfg *config.ClientAPI,
- rsAPI roomserverAPI.RoomserverInternalAPI, stateAPI currentstateAPI.CurrentStateInternalAPI,
+ rsAPI roomserverAPI.RoomserverInternalAPI,
) util.JSONResponse {
- resErr := checkMemberInRoom(req.Context(), stateAPI, device.UserID, roomID)
+ resErr := checkMemberInRoom(req.Context(), rsAPI, device.UserID, roomID)
if resErr != nil {
return *resErr
}
@@ -67,7 +66,7 @@ func SendRedaction(
// https://matrix.org/docs/spec/client_server/r0.6.1#put-matrix-client-r0-rooms-roomid-redact-eventid-txnid
allowedToRedact := ev.Sender() == device.UserID
if !allowedToRedact {
- plEvent := currentstateAPI.GetEvent(req.Context(), stateAPI, roomID, gomatrixserverlib.StateKeyTuple{
+ plEvent := roomserverAPI.GetStateEvent(req.Context(), rsAPI, roomID, gomatrixserverlib.StateKeyTuple{
EventType: gomatrixserverlib.MRoomPowerLevels,
StateKey: "",
})
diff --git a/clientapi/routing/routing.go b/clientapi/routing/routing.go
index 14acc42f..708f6fee 100644
--- a/clientapi/routing/routing.go
+++ b/clientapi/routing/routing.go
@@ -165,7 +165,7 @@ func Setup(
if err != nil {
return util.ErrorResponse(err)
}
- return SendKick(req, accountDB, device, vars["roomID"], cfg, rsAPI, asAPI, stateAPI)
+ return SendKick(req, accountDB, device, vars["roomID"], cfg, rsAPI, asAPI)
}),
).Methods(http.MethodPost, http.MethodOptions)
r0mux.Handle("/rooms/{roomID}/unban",
@@ -361,7 +361,7 @@ func Setup(
if err != nil {
return util.ErrorResponse(err)
}
- return SendTyping(req, device, vars["roomID"], vars["userID"], accountDB, eduAPI, stateAPI)
+ return SendTyping(req, device, vars["roomID"], vars["userID"], accountDB, eduAPI, rsAPI)
}),
).Methods(http.MethodPut, http.MethodOptions)
r0mux.Handle("/rooms/{roomID}/redact/{eventID}",
@@ -370,7 +370,7 @@ func Setup(
if err != nil {
return util.ErrorResponse(err)
}
- return SendRedaction(req, device, vars["roomID"], vars["eventID"], cfg, rsAPI, stateAPI)
+ return SendRedaction(req, device, vars["roomID"], vars["eventID"], cfg, rsAPI)
}),
).Methods(http.MethodPost, http.MethodOptions)
r0mux.Handle("/rooms/{roomID}/redact/{eventID}/{txnId}",
@@ -379,7 +379,7 @@ func Setup(
if err != nil {
return util.ErrorResponse(err)
}
- return SendRedaction(req, device, vars["roomID"], vars["eventID"], cfg, rsAPI, stateAPI)
+ return SendRedaction(req, device, vars["roomID"], vars["eventID"], cfg, rsAPI)
}),
).Methods(http.MethodPut, http.MethodOptions)
diff --git a/clientapi/routing/sendtyping.go b/clientapi/routing/sendtyping.go
index e4b5b7a3..3abf3db2 100644
--- a/clientapi/routing/sendtyping.go
+++ b/clientapi/routing/sendtyping.go
@@ -17,8 +17,8 @@ import (
"github.com/matrix-org/dendrite/clientapi/httputil"
"github.com/matrix-org/dendrite/clientapi/jsonerror"
- currentstateAPI "github.com/matrix-org/dendrite/currentstateserver/api"
"github.com/matrix-org/dendrite/eduserver/api"
+ roomserverAPI "github.com/matrix-org/dendrite/roomserver/api"
userapi "github.com/matrix-org/dendrite/userapi/api"
"github.com/matrix-org/dendrite/userapi/storage/accounts"
"github.com/matrix-org/util"
@@ -35,7 +35,7 @@ func SendTyping(
req *http.Request, device *userapi.Device, roomID string,
userID string, accountDB accounts.Database,
eduAPI api.EDUServerInputAPI,
- stateAPI currentstateAPI.CurrentStateInternalAPI,
+ rsAPI roomserverAPI.RoomserverInternalAPI,
) util.JSONResponse {
if device.UserID != userID {
return util.JSONResponse{
@@ -45,7 +45,7 @@ func SendTyping(
}
// Verify that the user is a member of this room
- resErr := checkMemberInRoom(req.Context(), stateAPI, userID, roomID)
+ resErr := checkMemberInRoom(req.Context(), rsAPI, userID, roomID)
if resErr != nil {
return *resErr
}