From 3c419be6af2938170d2c04f56d8616c0129ca673 Mon Sep 17 00:00:00 2001 From: Kegsay Date: Mon, 8 Mar 2021 18:16:28 +0000 Subject: [PATCH] roomserver: don't make_join with ourselves if clients ask us to (#1797) * roomserver: don't make_join with ourselves if clients ask us to * delete properly --- roomserver/internal/perform/perform_join.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/roomserver/internal/perform/perform_join.go b/roomserver/internal/perform/perform_join.go index ada584a8..6eaaec23 100644 --- a/roomserver/internal/perform/perform_join.go +++ b/roomserver/internal/perform/perform_join.go @@ -151,6 +151,16 @@ func (r *Joiner) performJoinRoomByID( ctx context.Context, req *api.PerformJoinRequest, ) (string, gomatrixserverlib.ServerName, error) { + // The original client request ?server_name=... may include this HS so filter that out so we + // don't attempt to make_join with ourselves + for i := 0; i < len(req.ServerNames); i++ { + if req.ServerNames[i] == r.Cfg.Matrix.ServerName { + // delete this entry + req.ServerNames = append(req.ServerNames[:i], req.ServerNames[i+1:]...) + i-- + } + } + // Get the domain part of the room ID. _, domain, err := gomatrixserverlib.SplitID('!', req.RoomIDOrAlias) if err != nil {