mirror of
https://github.com/hoernschen/dendrite.git
synced 2024-12-27 07:28:27 +00:00
Try to find new servers to federated join via
This commit is contained in:
parent
f7c3f75e48
commit
2d91fe0df1
1 changed files with 28 additions and 3 deletions
|
@ -259,10 +259,35 @@ func (r *Joiner) performJoinRoomByID(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !success {
|
if !success {
|
||||||
return "", "", &api.PerformError{
|
queryReq := &api.QueryMembershipsForRoomRequest{}
|
||||||
Code: rsAPI.PerformErrorBadRequest,
|
queryRes := &api.QueryMembershipsForRoomResponse{}
|
||||||
Msg: fmt.Sprintf("Can't satisfy restricted join to room %q locally", req.RoomIDOrAlias),
|
if err = r.RSAPI.QueryMembershipsForRoom(ctx, queryReq, queryRes); err != nil {
|
||||||
|
return "", "", &api.PerformError{
|
||||||
|
Code: rsAPI.PerformErrorBadRequest,
|
||||||
|
Msg: fmt.Sprintf("Can't satisfy restricted join to room %q locally: %s", req.RoomIDOrAlias, err),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var serverName gomatrixserverlib.ServerName
|
||||||
|
joinEvents:
|
||||||
|
for _, q := range queryRes.JoinEvents {
|
||||||
|
_, serverName, err = gomatrixserverlib.SplitID('@', *q.StateKey)
|
||||||
|
if err != nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
for _, s := range req.ServerNames {
|
||||||
|
if s == r.Cfg.Matrix.ServerName {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if s == serverName {
|
||||||
|
continue joinEvents
|
||||||
|
}
|
||||||
|
}
|
||||||
|
req.ServerNames = append(req.ServerNames, serverName)
|
||||||
|
}
|
||||||
|
|
||||||
|
joinedVia, err = r.performFederatedJoinRoomByID(ctx, req)
|
||||||
|
return req.RoomIDOrAlias, joinedVia, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue