Don't default to federated room joins in response to invite

This commit is contained in:
Neil Alexander 2020-05-26 10:31:27 +01:00
parent 107937749b
commit b2dc3f9f49

View file

@ -127,14 +127,23 @@ func (r *RoomserverInternalAPI) performJoinRoomByID(
// latest state as all of our users have left. // latest state as all of our users have left.
isInvitePending, inviteSender, err := r.isInvitePending(ctx, req.RoomIDOrAlias, req.UserID) isInvitePending, inviteSender, err := r.isInvitePending(ctx, req.RoomIDOrAlias, req.UserID)
if err == nil && isInvitePending { if err == nil && isInvitePending {
// Add the server of the person who invited us to the server list, // Check if there's an invite pending.
// as they should be a fairly good bet. _, inviterDomain, ierr := gomatrixserverlib.SplitID('@', inviteSender)
if _, inviterDomain, ierr := gomatrixserverlib.SplitID('@', inviteSender); ierr == nil { if ierr != nil {
req.ServerNames = append(req.ServerNames, inviterDomain) return fmt.Errorf("gomatrixserverlib.SplitID: %w", err)
} }
// Perform a federated room join. // Check that the domain isn't ours. If it's local then we don't
return r.performFederatedJoinRoomByID(ctx, req, res) // need to do anythig 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. // Try to construct an actual join event from the template.