Return correct room ID from PerformJoin

This commit is contained in:
Neil Alexander 2020-05-26 12:19:31 +01:00
parent 19615cc730
commit da20f270c6
3 changed files with 8 additions and 1 deletions

View file

@ -75,6 +75,6 @@ func JoinRoomByIDOrAlias(
// TODO: Put the response struct somewhere internal. // TODO: Put the response struct somewhere internal.
JSON: struct { JSON: struct {
RoomID string `json:"room_id"` RoomID string `json:"room_id"`
}{joinReq.RoomIDOrAlias}, }{joinRes.RoomID},
} }
} }

View file

@ -24,6 +24,7 @@ type PerformJoinRequest struct {
} }
type PerformJoinResponse struct { type PerformJoinResponse struct {
RoomID string `json:"room_id"`
} }
func (h *httpRoomserverInternalAPI) PerformJoin( func (h *httpRoomserverInternalAPI) PerformJoin(

View file

@ -90,6 +90,12 @@ func (r *RoomserverInternalAPI) performJoinRoomByID(
req *api.PerformJoinRequest, req *api.PerformJoinRequest,
res *api.PerformJoinResponse, // nolint:unparam res *api.PerformJoinResponse, // nolint:unparam
) error { ) 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. // Get the domain part of the room ID.
_, domain, err := gomatrixserverlib.SplitID('!', req.RoomIDOrAlias) _, domain, err := gomatrixserverlib.SplitID('!', req.RoomIDOrAlias)
if err != nil { if err != nil {