diff options
author | Neil Alexander <neilalexander@users.noreply.github.com> | 2020-05-26 14:41:16 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-26 14:41:16 +0100 |
commit | 6d50212f29f2ce3231097833de7686e3237359b4 (patch) | |
tree | 918e8badc8e9eb6f34fc16a206099669dd1f58a3 /roomserver | |
parent | 492af0f2ec3850d41dd02c9c512de8361d50d271 (diff) |
Miscellaneous fixes (#1060)
* Add missing routing for PerformDirectoryLookupRequest
* Tweak output
* Fix some bugs in devices
* Don't default to federated room joins in response to invite
* Update sytest-whitelist
* Update comments
* Return correct room ID from PerformJoin
* Fix appservice and EDU server API setup, update sytest-whitelist
* Update sytest-whitelist
Diffstat (limited to 'roomserver')
-rw-r--r-- | roomserver/api/perform.go | 1 | ||||
-rw-r--r-- | roomserver/internal/perform_join.go | 36 |
2 files changed, 27 insertions, 10 deletions
diff --git a/roomserver/api/perform.go b/roomserver/api/perform.go index c98f91fb..f5afd67b 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 dc786b29..75dfdd19 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 { @@ -121,20 +127,30 @@ func (r *RoomserverInternalAPI) performJoinRoomByID( return fmt.Errorf("eb.SetContent: %w", err) } - // First work out if this is in response to an existing invite. - // If it is then we avoid the situation where we might think we - // know about a room in the following section but don't know the - // latest state as all of our users have left. + // First work out if this is in response to an existing invite + // from a federated server. If it is then we avoid the situation + // where we might think we know about a room in the following + // section but don't know the latest state as all of our users + // have left. isInvitePending, inviteSender, err := r.isInvitePending(ctx, req.RoomIDOrAlias, req.UserID) if err == nil && isInvitePending { - // Add the server of the person who invited us to the server list, - // as they should be a fairly good bet. - if _, inviterDomain, ierr := gomatrixserverlib.SplitID('@', inviteSender); ierr == nil { - req.ServerNames = append(req.ServerNames, inviterDomain) + // Check if there's an invite pending. + _, inviterDomain, ierr := gomatrixserverlib.SplitID('@', inviteSender) + if ierr != nil { + return fmt.Errorf("gomatrixserverlib.SplitID: %w", err) } - // Perform a federated room join. - return r.performFederatedJoinRoomByID(ctx, req, res) + // Check that the domain isn't ours. If it's local then we don't + // need to do anything as our own copy of the room state will be + // up-to-date. + if inviterDomain != r.Cfg.Matrix.ServerName { + // Add the server of the person who invited us to the server list, + // as they should be a fairly good bet. + req.ServerNames = append(req.ServerNames, inviterDomain) + + // Perform a federated room join. + return r.performFederatedJoinRoomByID(ctx, req, res) + } } // Try to construct an actual join event from the template. |