From da20f270c6d6ca28192a6fa49f38241ce5a121e5 Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Tue, 26 May 2020 12:19:31 +0100 Subject: [PATCH] Return correct room ID from PerformJoin --- clientapi/routing/joinroom.go | 2 +- roomserver/api/perform.go | 1 + roomserver/internal/perform_join.go | 6 ++++++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/clientapi/routing/joinroom.go b/clientapi/routing/joinroom.go index 500df337a..a3d676532 100644 --- a/clientapi/routing/joinroom.go +++ b/clientapi/routing/joinroom.go @@ -75,6 +75,6 @@ func JoinRoomByIDOrAlias( // TODO: Put the response struct somewhere internal. JSON: struct { RoomID string `json:"room_id"` - }{joinReq.RoomIDOrAlias}, + }{joinRes.RoomID}, } } diff --git a/roomserver/api/perform.go b/roomserver/api/perform.go index c98f91fb4..f5afd67bf 100644 --- a/roomserver/api/perform.go +++ b/roomserver/api/perform.go @@ -24,6 +24,7 @@ type PerformJoinRequest struct { } type PerformJoinResponse struct { + RoomID string `json:"room_id"` } func (h *httpRoomserverInternalAPI) PerformJoin( diff --git a/roomserver/internal/perform_join.go b/roomserver/internal/perform_join.go index ce158f605..75dfdd19c 100644 --- a/roomserver/internal/perform_join.go +++ b/roomserver/internal/perform_join.go @@ -90,6 +90,12 @@ func (r *RoomserverInternalAPI) performJoinRoomByID( req *api.PerformJoinRequest, res *api.PerformJoinResponse, // nolint:unparam ) error { + // By this point, if req.RoomIDOrAlias contained an alias, then + // it will have been overwritten with a room ID by performJoinRoomByAlias. + // We should now include this in the response so that the CS API can + // return the right room ID. + res.RoomID = req.RoomIDOrAlias + // Get the domain part of the room ID. _, domain, err := gomatrixserverlib.SplitID('!', req.RoomIDOrAlias) if err != nil {