From cc5d1ee213c3aa50bf3c2d94d982b243fbe3e5af Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Fri, 1 May 2020 16:38:48 +0100 Subject: [PATCH] Fix local server checks --- roomserver/internal/perform_join.go | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/roomserver/internal/perform_join.go b/roomserver/internal/perform_join.go index cda2ab3e5..8e84bdf60 100644 --- a/roomserver/internal/perform_join.go +++ b/roomserver/internal/perform_join.go @@ -66,9 +66,9 @@ func (r *RoomserverInternalAPI) performJoinRoomByID( res *api.PerformJoinResponse, // nolint:unparam ) error { // Get the domain part of the room ID. - _, domain, err := gomatrixserverlib.SplitID('#', req.RoomIDOrAlias) + _, domain, err := gomatrixserverlib.SplitID('!', req.RoomIDOrAlias) if err != nil { - return fmt.Errorf("supplied room alias %q in incorrect format", req.RoomIDOrAlias) + return fmt.Errorf("supplied room ID %q in incorrect format", req.RoomIDOrAlias) } req.ServerNames = append(req.ServerNames, domain) @@ -134,10 +134,7 @@ func (r *RoomserverInternalAPI) performJoinRoomByID( // The room doesn't exist. First of all check if the room is a local // room. If it is then there's nothing more to do - the room just // hasn't been created yet. - _, domain, derr := gomatrixserverlib.SplitID('!', req.RoomIDOrAlias) - if derr != nil { - return fmt.Errorf("room ID %q in incorrect format", req.RoomIDOrAlias) - } else if domain == r.Cfg.Matrix.ServerName { + if domain == r.Cfg.Matrix.ServerName { return fmt.Errorf("error trying to join %q room: %w", req.RoomIDOrAlias, derr) }