aboutsummaryrefslogtreecommitdiff
path: root/federationapi/routing/devices.go
diff options
context:
space:
mode:
authorKegsay <kegan@matrix.org>2020-06-16 14:53:19 +0100
committerGitHub <noreply@github.com>2020-06-16 14:53:19 +0100
commit1942928ee5e0398beed45c8b1c63d7b13e89b646 (patch)
tree0313e9168df851bd1eef314bbc04aed301114e4c /federationapi/routing/devices.go
parent45011579eb65842821dff73fc2028db9d6bf7b93 (diff)
Make federationapi use userapi (#1135)
Removes dependencies on account DB, device DB and ASAPI.
Diffstat (limited to 'federationapi/routing/devices.go')
-rw-r--r--federationapi/routing/devices.go22
1 files changed, 8 insertions, 14 deletions
diff --git a/federationapi/routing/devices.go b/federationapi/routing/devices.go
index caf5fe59..6369c708 100644
--- a/federationapi/routing/devices.go
+++ b/federationapi/routing/devices.go
@@ -15,9 +15,8 @@ package routing
import (
"net/http"
- "github.com/matrix-org/dendrite/clientapi/auth/storage/devices"
"github.com/matrix-org/dendrite/clientapi/jsonerror"
- "github.com/matrix-org/dendrite/clientapi/userutil"
+ userapi "github.com/matrix-org/dendrite/userapi/api"
"github.com/matrix-org/gomatrixserverlib"
"github.com/matrix-org/util"
)
@@ -25,17 +24,9 @@ import (
// GetUserDevices for the given user id
func GetUserDevices(
req *http.Request,
- deviceDB devices.Database,
+ userAPI userapi.UserInternalAPI,
userID string,
) util.JSONResponse {
- localpart, err := userutil.ParseUsernameParam(userID, nil)
- if err != nil {
- return util.JSONResponse{
- Code: http.StatusBadRequest,
- JSON: jsonerror.InvalidArgumentValue("Invalid user ID"),
- }
- }
-
response := gomatrixserverlib.RespUserDevices{
UserID: userID,
// TODO: we should return an incrementing stream ID each time the device
@@ -43,13 +34,16 @@ func GetUserDevices(
StreamID: 0,
}
- devs, err := deviceDB.GetDevicesByLocalpart(req.Context(), localpart)
+ var res userapi.QueryDevicesResponse
+ err := userAPI.QueryDevices(req.Context(), &userapi.QueryDevicesRequest{
+ UserID: userID,
+ }, &res)
if err != nil {
- util.GetLogger(req.Context()).WithError(err).Error("deviceDB.GetDevicesByLocalPart failed")
+ util.GetLogger(req.Context()).WithError(err).Error("userAPI.QueryDevices failed")
return jsonerror.InternalServerError()
}
- for _, dev := range devs {
+ for _, dev := range res.Devices {
device := gomatrixserverlib.RespUserDevice{
DeviceID: dev.ID,
DisplayName: dev.DisplayName,