mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-23 14:53:10 -06:00
Don't send our membership event twice
This commit is contained in:
parent
f1b76541ea
commit
746e105888
|
|
@ -108,6 +108,7 @@ func (r *FederationSenderInternalAPI) PerformJoin(
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// nolint:gocyclo
|
||||||
func (r *FederationSenderInternalAPI) performJoinUsingServer(
|
func (r *FederationSenderInternalAPI) performJoinUsingServer(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
roomID, userID string,
|
roomID, userID string,
|
||||||
|
|
@ -192,6 +193,19 @@ func (r *FederationSenderInternalAPI) performJoinUsingServer(
|
||||||
return fmt.Errorf("joinCtx.CheckSendJoinResponse: %w", err)
|
return fmt.Errorf("joinCtx.CheckSendJoinResponse: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// It's possible that the remote server has included our new
|
||||||
|
// membership event in the room state in the send_join response,
|
||||||
|
// but if that's the case, then we'll get a duplicate state block
|
||||||
|
// error if we try to send that along with our own copy of the
|
||||||
|
// event. The simple way around this is just to prune the event
|
||||||
|
// from the state if we find it.
|
||||||
|
for i, ev := range respState.StateEvents {
|
||||||
|
if ev.Type() == gomatrixserverlib.MRoomMember && ev.StateKeyEquals(userID) {
|
||||||
|
respState.StateEvents = append(respState.StateEvents[i:], respState.StateEvents[:i+1]...)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// If we successfully performed a send_join above then the other
|
// If we successfully performed a send_join above then the other
|
||||||
// server now thinks we're a part of the room. Send the newly
|
// server now thinks we're a part of the room. Send the newly
|
||||||
// returned state to the roomserver to update our local view.
|
// returned state to the roomserver to update our local view.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue