mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-23 14:53:10 -06:00
Fix federated join check
This commit is contained in:
parent
436c0aafc5
commit
9c8cc2f34f
|
|
@ -183,31 +183,34 @@ func (r *Joiner) performJoinRoomByID(
|
||||||
return "", fmt.Errorf("eb.SetContent: %w", err)
|
return "", fmt.Errorf("eb.SetContent: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// First work out if this is in response to an existing invite
|
// Work out if this should be a federated join. This will be true
|
||||||
// from a federated server. If it is then we avoid the situation
|
// if our server isn't joined to this room already, or in response
|
||||||
// where we might think we know about a room in the following
|
// to an existing invite from a federated server. If it is then we
|
||||||
// section but don't know the latest state as all of our users
|
// avoid the situation where we might think we know about a room
|
||||||
// have left.
|
// in the following section but don't know the latest state as all
|
||||||
|
// of our users have left.
|
||||||
serverInRoom, _ := helpers.IsServerCurrentlyInRoom(ctx, r.DB, r.ServerName, req.RoomIDOrAlias)
|
serverInRoom, _ := helpers.IsServerCurrentlyInRoom(ctx, r.DB, r.ServerName, req.RoomIDOrAlias)
|
||||||
isInvitePending, inviteSender, _, err := helpers.IsInvitePending(ctx, r.DB, req.RoomIDOrAlias, req.UserID)
|
isInvitePending, inviteSender, _, err := helpers.IsInvitePending(ctx, r.DB, req.RoomIDOrAlias, req.UserID)
|
||||||
if err == nil && isInvitePending && !serverInRoom {
|
if !serverInRoom || (err == nil && isInvitePending) {
|
||||||
// Check if there's an invite pending.
|
if inviteSender != "" {
|
||||||
_, inviterDomain, ierr := gomatrixserverlib.SplitID('@', inviteSender)
|
// Check if there's an invite pending.
|
||||||
if ierr != nil {
|
_, inviterDomain, ierr := gomatrixserverlib.SplitID('@', inviteSender)
|
||||||
return "", fmt.Errorf("gomatrixserverlib.SplitID: %w", err)
|
if ierr != nil {
|
||||||
|
return "", fmt.Errorf("gomatrixserverlib.SplitID: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check that the domain isn't ours. If it's local then we don't
|
||||||
|
// need to do anything 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)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check that the domain isn't ours. If it's local then we don't
|
// Perform a federated room join.
|
||||||
// need to do anything as our own copy of the room state will be
|
return req.RoomIDOrAlias, r.performFederatedJoinRoomByID(ctx, req)
|
||||||
// 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 req.RoomIDOrAlias, r.performFederatedJoinRoomByID(ctx, req)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Try to construct an actual join event from the template.
|
// Try to construct an actual join event from the template.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue