aboutsummaryrefslogtreecommitdiff
path: root/clientapi/routing/joined_rooms.go
diff options
context:
space:
mode:
Diffstat (limited to 'clientapi/routing/joined_rooms.go')
-rw-r--r--clientapi/routing/joined_rooms.go31
1 files changed, 22 insertions, 9 deletions
diff --git a/clientapi/routing/joined_rooms.go b/clientapi/routing/joined_rooms.go
index f664183f..3fe0d8b4 100644
--- a/clientapi/routing/joined_rooms.go
+++ b/clientapi/routing/joined_rooms.go
@@ -33,23 +33,36 @@ func GetJoinedRooms(
device *userapi.Device,
rsAPI api.ClientRoomserverAPI,
) util.JSONResponse {
- var res api.QueryRoomsForUserResponse
- err := rsAPI.QueryRoomsForUser(req.Context(), &api.QueryRoomsForUserRequest{
- UserID: device.UserID,
- WantMembership: "join",
- }, &res)
+ deviceUserID, err := spec.NewUserID(device.UserID, true)
+ if err != nil {
+ util.GetLogger(req.Context()).WithError(err).Error("Invalid device user ID")
+ return util.JSONResponse{
+ Code: http.StatusInternalServerError,
+ JSON: spec.Unknown("internal server error"),
+ }
+ }
+
+ rooms, err := rsAPI.QueryRoomsForUser(req.Context(), *deviceUserID, "join")
if err != nil {
util.GetLogger(req.Context()).WithError(err).Error("QueryRoomsForUser failed")
return util.JSONResponse{
Code: http.StatusInternalServerError,
- JSON: spec.InternalServerError{},
+ JSON: spec.Unknown("internal server error"),
}
}
- if res.RoomIDs == nil {
- res.RoomIDs = []string{}
+
+ var roomIDStrs []string
+ if rooms == nil {
+ roomIDStrs = []string{}
+ } else {
+ roomIDStrs = make([]string, len(rooms))
+ for i, roomID := range rooms {
+ roomIDStrs[i] = roomID.String()
+ }
}
+
return util.JSONResponse{
Code: http.StatusOK,
- JSON: getJoinedRoomsResponse{res.RoomIDs},
+ JSON: getJoinedRoomsResponse{roomIDStrs},
}
}