mirror of
https://github.com/matrix-org/dendrite.git
synced 2024-11-26 08:11:55 -06:00
lookupEvent sends outliers
This commit is contained in:
parent
2951eb20af
commit
3e16556441
|
@ -416,38 +416,13 @@ func (t *txnReq) retrieveMissingAuthEvents(
|
||||||
if len(servers) > 5 {
|
if len(servers) > 5 {
|
||||||
servers = servers[:5]
|
servers = servers[:5]
|
||||||
}
|
}
|
||||||
withNextEvent:
|
|
||||||
for missingAuthEventID := range missingAuthEvents {
|
for missingAuthEventID := range missingAuthEvents {
|
||||||
withNextServer:
|
if _, err := t.lookupEvent(ctx, stateResp.RoomVersion, missingAuthEventID, true, servers); err != nil {
|
||||||
for _, server := range servers {
|
logger.WithError(err).Warnf("Failed to retrieve auth event %q", missingAuthEventID)
|
||||||
logger.Infof("Retrieving missing auth event %q from %q", missingAuthEventID, server)
|
continue
|
||||||
tx, err := t.federation.GetEvent(ctx, server, missingAuthEventID)
|
|
||||||
if err != nil {
|
|
||||||
logger.WithError(err).Warnf("Failed to retrieve auth event %q", missingAuthEventID)
|
|
||||||
continue withNextServer
|
|
||||||
}
|
|
||||||
ev, err := gomatrixserverlib.NewEventFromUntrustedJSON(tx.PDUs[0], stateResp.RoomVersion)
|
|
||||||
if err != nil {
|
|
||||||
logger.WithError(err).Warnf("Failed to unmarshal auth event %q", missingAuthEventID)
|
|
||||||
continue withNextServer
|
|
||||||
}
|
|
||||||
if err = api.SendInputRoomEvents(
|
|
||||||
context.Background(),
|
|
||||||
t.rsAPI,
|
|
||||||
[]api.InputRoomEvent{
|
|
||||||
{
|
|
||||||
Kind: api.KindOutlier,
|
|
||||||
Event: ev.Headered(stateResp.RoomVersion),
|
|
||||||
AuthEventIDs: ev.AuthEventIDs(),
|
|
||||||
SendAsServer: api.DoNotSendToOtherServers,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
); err != nil {
|
|
||||||
return fmt.Errorf("api.SendEvents: %w", err)
|
|
||||||
}
|
|
||||||
delete(missingAuthEvents, missingAuthEventID)
|
|
||||||
continue withNextEvent
|
|
||||||
}
|
}
|
||||||
|
delete(missingAuthEvents, missingAuthEventID)
|
||||||
}
|
}
|
||||||
|
|
||||||
if missing := len(missingAuthEvents); missing > 0 {
|
if missing := len(missingAuthEvents); missing > 0 {
|
||||||
|
@ -1041,6 +1016,20 @@ func (t *txnReq) lookupEvent(ctx context.Context, roomVersion gomatrixserverlib.
|
||||||
return nil, verifySigError{event.EventID(), err}
|
return nil, verifySigError{event.EventID(), err}
|
||||||
}
|
}
|
||||||
h := event.Headered(roomVersion)
|
h := event.Headered(roomVersion)
|
||||||
|
if err := api.SendInputRoomEvents(
|
||||||
|
context.Background(),
|
||||||
|
t.rsAPI,
|
||||||
|
[]api.InputRoomEvent{
|
||||||
|
{
|
||||||
|
Kind: api.KindOutlier,
|
||||||
|
Event: h,
|
||||||
|
AuthEventIDs: h.AuthEventIDs(),
|
||||||
|
SendAsServer: api.DoNotSendToOtherServers,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
); err != nil {
|
||||||
|
return nil, fmt.Errorf("api.SendInputRoomEvents: %w", err)
|
||||||
|
}
|
||||||
t.newEvents[h.EventID()] = true
|
t.newEvents[h.EventID()] = true
|
||||||
return &h, nil
|
return &h, nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue