Ignore depth in federation API (#1451)
This commit is contained in:
parent
b0d5d1cc9f
commit
43cdba9a69
2 changed files with 6 additions and 13 deletions
|
@ -26,7 +26,7 @@ type getMissingEventRequest struct {
|
|||
EarliestEvents []string `json:"earliest_events"`
|
||||
LatestEvents []string `json:"latest_events"`
|
||||
Limit int `json:"limit"`
|
||||
MinDepth int64 `json:"min_depth"`
|
||||
MinDepth int64 `json:"min_depth"` // not used
|
||||
}
|
||||
|
||||
// GetMissingEvents returns missing events between earliest_events & latest_events.
|
||||
|
@ -59,7 +59,7 @@ func GetMissingEvents(
|
|||
return jsonerror.InternalServerError()
|
||||
}
|
||||
|
||||
eventsResponse.Events = filterEvents(eventsResponse.Events, gme.MinDepth, roomID)
|
||||
eventsResponse.Events = filterEvents(eventsResponse.Events, roomID)
|
||||
|
||||
resp := gomatrixserverlib.RespMissingEvents{
|
||||
Events: gomatrixserverlib.UnwrapEventHeaders(eventsResponse.Events),
|
||||
|
@ -71,13 +71,13 @@ func GetMissingEvents(
|
|||
}
|
||||
}
|
||||
|
||||
// filterEvents returns only those events with matching roomID and having depth greater than minDepth
|
||||
// filterEvents returns only those events with matching roomID
|
||||
func filterEvents(
|
||||
events []gomatrixserverlib.HeaderedEvent, minDepth int64, roomID string,
|
||||
events []gomatrixserverlib.HeaderedEvent, roomID string,
|
||||
) []gomatrixserverlib.HeaderedEvent {
|
||||
ref := events[:0]
|
||||
for _, ev := range events {
|
||||
if ev.Depth() >= minDepth && ev.RoomID() == roomID {
|
||||
if ev.RoomID() == roomID {
|
||||
ref = append(ref, ev)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -656,7 +656,7 @@ retryAllowedState:
|
|||
// getMissingEvents returns a nil backwardsExtremity if missing events were fetched and handled, else returns the new backwards extremity which we should
|
||||
// begin from. Returns an error only if we should terminate the transaction which initiated /get_missing_events
|
||||
// This function recursively calls txnReq.processEvent with the missing events, which will be processed before this function returns.
|
||||
// This means that we may recursively call this function, as we spider back up prev_events to the min depth.
|
||||
// This means that we may recursively call this function, as we spider back up prev_events.
|
||||
// nolint:gocyclo
|
||||
func (t *txnReq) getMissingEvents(ctx context.Context, e gomatrixserverlib.Event, roomVersion gomatrixserverlib.RoomVersion, isInboundTxn bool) (backwardsExtremity *gomatrixserverlib.Event, err error) {
|
||||
if !isInboundTxn {
|
||||
|
@ -679,11 +679,6 @@ func (t *txnReq) getMissingEvents(ctx context.Context, e gomatrixserverlib.Event
|
|||
for i := range res.LatestEvents {
|
||||
latestEvents[i] = res.LatestEvents[i].EventID
|
||||
}
|
||||
// this server just sent us an event for which we do not know its prev_events - ask that server for those prev_events.
|
||||
minDepth := int(res.Depth) - 20
|
||||
if minDepth < 0 {
|
||||
minDepth = 0
|
||||
}
|
||||
|
||||
servers := []gomatrixserverlib.ServerName{t.Origin}
|
||||
serverReq := &api.QueryServerJoinedToRoomRequest{
|
||||
|
@ -700,8 +695,6 @@ func (t *txnReq) getMissingEvents(ctx context.Context, e gomatrixserverlib.Event
|
|||
var m gomatrixserverlib.RespMissingEvents
|
||||
if m, err = t.federation.LookupMissingEvents(ctx, server, e.RoomID(), gomatrixserverlib.MissingEvents{
|
||||
Limit: 20,
|
||||
// synapse uses the min depth they've ever seen in that room
|
||||
MinDepth: minDepth,
|
||||
// The latest event IDs that the sender already has. These are skipped when retrieving the previous events of latest_events.
|
||||
EarliestEvents: latestEvents,
|
||||
// The event IDs to retrieve the previous events for.
|
||||
|
|
Loading…
Reference in a new issue