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
This commit is contained in:
Kegsay 2021-03-08 18:16:28 +00:00 committed by GitHub
parent 77fb981da5
commit 3c419be6af
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -151,6 +151,16 @@ func (r *Joiner) performJoinRoomByID(
ctx context.Context, ctx context.Context,
req *api.PerformJoinRequest, req *api.PerformJoinRequest,
) (string, gomatrixserverlib.ServerName, error) { ) (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. // 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 {