mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-23 14:53:10 -06:00
Return early from federated room join
This commit is contained in:
parent
45de9dc1c0
commit
a3e401e5dd
|
|
@ -186,26 +186,38 @@ func (r *FederationSenderInternalAPI) performJoinUsingServer(
|
||||||
}
|
}
|
||||||
r.statistics.ForServer(serverName).Success()
|
r.statistics.ForServer(serverName).Success()
|
||||||
|
|
||||||
// Check that the send_join response was valid.
|
go func() {
|
||||||
joinCtx := perform.JoinContext(r.federation, r.keyRing)
|
ctx = context.Background()
|
||||||
respState, err := joinCtx.CheckSendJoinResponse(
|
|
||||||
ctx, event, serverName, respMakeJoin, respSendJoin,
|
|
||||||
)
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("joinCtx.CheckSendJoinResponse: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
// If we successfully performed a send_join above then the other
|
// Check that the send_join response was valid.
|
||||||
// server now thinks we're a part of the room. Send the newly
|
joinCtx := perform.JoinContext(r.federation, r.keyRing)
|
||||||
// returned state to the roomserver to update our local view.
|
respState, err := joinCtx.CheckSendJoinResponse(
|
||||||
if err = roomserverAPI.SendEventWithRewrite(
|
ctx, event, serverName, respMakeJoin, respSendJoin,
|
||||||
ctx, r.rsAPI,
|
)
|
||||||
respState,
|
if err != nil {
|
||||||
event.Headered(respMakeJoin.RoomVersion),
|
logrus.WithFields(logrus.Fields{
|
||||||
nil,
|
"room_id": roomID,
|
||||||
); err != nil {
|
"user_id": userID,
|
||||||
return fmt.Errorf("r.producer.SendEventWithState: %w", err)
|
}).WithError(err).Error("Failed to process room join response")
|
||||||
}
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// If we successfully performed a send_join above then the other
|
||||||
|
// server now thinks we're a part of the room. Send the newly
|
||||||
|
// returned state to the roomserver to update our local view.
|
||||||
|
if err = roomserverAPI.SendEventWithRewrite(
|
||||||
|
ctx, r.rsAPI,
|
||||||
|
respState,
|
||||||
|
event.Headered(respMakeJoin.RoomVersion),
|
||||||
|
nil,
|
||||||
|
); err != nil {
|
||||||
|
logrus.WithFields(logrus.Fields{
|
||||||
|
"room_id": roomID,
|
||||||
|
"user_id": userID,
|
||||||
|
}).WithError(err).Error("Failed to send room join response to roomserver")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue