mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-23 14:53:10 -06:00
fix api.SendEventWithState with no event
This commit is contained in:
parent
a160c074e8
commit
32f898d668
|
|
@ -459,7 +459,7 @@ func (t *txnReq) processEventWithMissingState(ctx context.Context, e gomatrixser
|
||||||
// pass the event along with the state to the roomserver using a background context so we don't
|
// pass the event along with the state to the roomserver using a background context so we don't
|
||||||
// needlessly expire
|
// needlessly expire
|
||||||
headeredEvent := e.Headered(roomVersion)
|
headeredEvent := e.Headered(roomVersion)
|
||||||
return api.SendEventWithState(context.Background(), t.rsAPI, resolvedState, &headeredEvent, t.haveEventIDs())
|
return api.SendEventWithState(context.Background(), t.rsAPI, resolvedState, &headeredEvent, t.haveEventIDs(), roomVersion)
|
||||||
}
|
}
|
||||||
|
|
||||||
// lookupStateAfterEvent returns the room state after `eventID`, which is the state before eventID with the state of `eventID` (if it's a state event)
|
// lookupStateAfterEvent returns the room state after `eventID`, which is the state before eventID with the state of `eventID` (if it's a state event)
|
||||||
|
|
|
||||||
|
|
@ -201,6 +201,7 @@ func (r *FederationSenderInternalAPI) performJoinUsingServer(
|
||||||
respState,
|
respState,
|
||||||
&headeredEvent,
|
&headeredEvent,
|
||||||
nil,
|
nil,
|
||||||
|
respMakeJoin.RoomVersion,
|
||||||
); err != nil {
|
); err != nil {
|
||||||
return fmt.Errorf("r.producer.SendEventWithState: %w", err)
|
return fmt.Errorf("r.producer.SendEventWithState: %w", err)
|
||||||
}
|
}
|
||||||
|
|
@ -310,7 +311,7 @@ func (r *FederationSenderInternalAPI) performOutboundPeekUsingServer(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Try to perform a /peek using the information supplied in the
|
// Try to perform an outbound /peek using the information supplied in the
|
||||||
// request.
|
// request.
|
||||||
respPeek, err := r.federation.Peek(
|
respPeek, err := r.federation.Peek(
|
||||||
ctx,
|
ctx,
|
||||||
|
|
@ -321,12 +322,12 @@ func (r *FederationSenderInternalAPI) performOutboundPeekUsingServer(
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
r.statistics.ForServer(serverName).Failure()
|
r.statistics.ForServer(serverName).Failure()
|
||||||
return fmt.Errorf("r.federation.MakePeek: %w", err)
|
return fmt.Errorf("r.federation.Peek: %w", err)
|
||||||
}
|
}
|
||||||
r.statistics.ForServer(serverName).Success()
|
r.statistics.ForServer(serverName).Success()
|
||||||
|
|
||||||
// Work out if we support the room version that has been supplied in
|
// Work out if we support the room version that has been supplied in
|
||||||
// the make_peek response.
|
// the peek response.
|
||||||
if respPeek.RoomVersion == "" {
|
if respPeek.RoomVersion == "" {
|
||||||
respPeek.RoomVersion = gomatrixserverlib.RoomVersionV1
|
respPeek.RoomVersion = gomatrixserverlib.RoomVersionV1
|
||||||
}
|
}
|
||||||
|
|
@ -349,11 +350,13 @@ func (r *FederationSenderInternalAPI) performOutboundPeekUsingServer(
|
||||||
}
|
}
|
||||||
|
|
||||||
respState := respPeek.ToRespState()
|
respState := respPeek.ToRespState()
|
||||||
|
// logrus.Warnf("converted respPeek %#v to respState %#v", respPeek, respState)
|
||||||
// Send the newly returned state to the roomserver to update our local view.
|
// Send the newly returned state to the roomserver to update our local view.
|
||||||
if err = roomserverAPI.SendEventWithState(
|
if err = roomserverAPI.SendEventWithState(
|
||||||
ctx, r.rsAPI,
|
ctx, r.rsAPI,
|
||||||
&respState,
|
&respState,
|
||||||
nil, nil,
|
nil, nil,
|
||||||
|
respPeek.RoomVersion,
|
||||||
); err != nil {
|
); err != nil {
|
||||||
return fmt.Errorf("r.producer.SendEventWithState: %w", err)
|
return fmt.Errorf("r.producer.SendEventWithState: %w", err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,7 @@ func SendEvents(
|
||||||
func SendEventWithState(
|
func SendEventWithState(
|
||||||
ctx context.Context, rsAPI RoomserverInternalAPI, state *gomatrixserverlib.RespState,
|
ctx context.Context, rsAPI RoomserverInternalAPI, state *gomatrixserverlib.RespState,
|
||||||
event *gomatrixserverlib.HeaderedEvent, haveEventIDs map[string]bool,
|
event *gomatrixserverlib.HeaderedEvent, haveEventIDs map[string]bool,
|
||||||
|
roomVersion gomatrixserverlib.RoomVersion,
|
||||||
) error {
|
) error {
|
||||||
outliers, err := state.Events()
|
outliers, err := state.Events()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -60,7 +61,7 @@ func SendEventWithState(
|
||||||
}
|
}
|
||||||
ires = append(ires, InputRoomEvent{
|
ires = append(ires, InputRoomEvent{
|
||||||
Kind: KindOutlier,
|
Kind: KindOutlier,
|
||||||
Event: outlier.Headered(event.RoomVersion),
|
Event: outlier.Headered(roomVersion),
|
||||||
AuthEventIDs: outlier.AuthEventIDs(),
|
AuthEventIDs: outlier.AuthEventIDs(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue