mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-17 03:43:11 -06:00
Return sooner when joining room over federation
This commit is contained in:
parent
77fe509031
commit
14398e0020
|
|
@ -332,6 +332,7 @@ func (r joinRoomReq) joinRoomUsingServer(roomID string, server gomatrixserverlib
|
||||||
RoomID: roomID,
|
RoomID: roomID,
|
||||||
UserID: r.userID,
|
UserID: r.userID,
|
||||||
ServerName: server,
|
ServerName: server,
|
||||||
|
Content: r.content,
|
||||||
}
|
}
|
||||||
fedJoinRes := federationSenderAPI.PerformJoinResponse{}
|
fedJoinRes := federationSenderAPI.PerformJoinResponse{}
|
||||||
if err := r.fsAPI.PerformJoin(r.req.Context(), &fedJoinReq, &fedJoinRes); err != nil {
|
if err := r.fsAPI.PerformJoin(r.req.Context(), &fedJoinReq, &fedJoinRes); err != nil {
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ import (
|
||||||
"github.com/matrix-org/dendrite/federationsender/query/perform"
|
"github.com/matrix-org/dendrite/federationsender/query/perform"
|
||||||
"github.com/matrix-org/dendrite/roomserver/version"
|
"github.com/matrix-org/dendrite/roomserver/version"
|
||||||
"github.com/matrix-org/gomatrixserverlib"
|
"github.com/matrix-org/gomatrixserverlib"
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
// PerformJoinRequest implements api.FederationSenderInternalAPI
|
// PerformJoinRequest implements api.FederationSenderInternalAPI
|
||||||
|
|
@ -87,24 +88,42 @@ func (r *FederationSenderInternalAPI) PerformJoin(
|
||||||
return fmt.Errorf("r.federation.SendJoin: %w", err)
|
return fmt.Errorf("r.federation.SendJoin: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check that the send_join response was valid.
|
// At this point, if the above /send_join didn't return an error,
|
||||||
joinCtx := perform.JoinContext(r.federation, r.keyRing)
|
// then the resident servers think we're in the room. We need
|
||||||
if err = joinCtx.CheckSendJoinResponse(
|
// to verify the state and auth chain and notify the roomserver
|
||||||
ctx, event, request.ServerName, respMakeJoin, respSendJoin,
|
// but this can take an awful long time in big rooms and there's
|
||||||
); err != nil {
|
// every possibility that client may give up waiting on this CS
|
||||||
return fmt.Errorf("perform.JoinRequest.CheckSendJoinResponse: %w", err)
|
// API request long before that. Therefore for now, until we
|
||||||
}
|
// have a /confirm_join step, just let the client think that the
|
||||||
|
// request succeeded and work it out in our own time. There's
|
||||||
|
// every possibility this might fail, and if so, the room will
|
||||||
|
// just never appear in the sync stream. That's about the best
|
||||||
|
// we can do for now.
|
||||||
|
go func() {
|
||||||
|
// Don't expire with the original request context.
|
||||||
|
ctx := context.Background()
|
||||||
|
|
||||||
// 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.
|
if err = joinCtx.CheckSendJoinResponse(
|
||||||
if err = r.producer.SendEventWithState(
|
ctx, event, request.ServerName, respMakeJoin, respSendJoin,
|
||||||
ctx,
|
); err != nil {
|
||||||
respSendJoin.ToRespState(),
|
logrus.WithError(err).Errorf("perform.JoinRequest.CheckSendJoinResponse failed")
|
||||||
event.Headered(respMakeJoin.RoomVersion),
|
return
|
||||||
); err != nil {
|
}
|
||||||
return fmt.Errorf("r.producer.SendEventWithState: %w", err)
|
|
||||||
}
|
// 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 = r.producer.SendEventWithState(
|
||||||
|
ctx,
|
||||||
|
respSendJoin.ToRespState(),
|
||||||
|
event.Headered(respMakeJoin.RoomVersion),
|
||||||
|
); err != nil {
|
||||||
|
logrus.WithError(err).Errorf("r.producer.SendEventWithState failed")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
// Everything went to plan.
|
// Everything went to plan.
|
||||||
return nil
|
return nil
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue