mirror of
https://github.com/hoernschen/dendrite.git
synced 2025-07-29 12:42:46 +00:00
Federation consumer adds_state_event_ids
tweak (#2441)
* Don't ask roomserver for events we already have in federation API * Check number of events returned is as expected * Preallocate array * Improve shape a bit
This commit is contained in:
parent
1a7f4c8aa9
commit
79da75d483
3 changed files with 28 additions and 33 deletions
|
@ -163,6 +163,19 @@ type OutputNewRoomEvent struct {
|
|||
TransactionID *TransactionID `json:"transaction_id,omitempty"`
|
||||
}
|
||||
|
||||
func (o *OutputNewRoomEvent) NeededStateEventIDs() ([]*gomatrixserverlib.HeaderedEvent, []string) {
|
||||
addsStateEvents := make([]*gomatrixserverlib.HeaderedEvent, 0, 1)
|
||||
missingEventIDs := make([]string, 0, len(o.AddsStateEventIDs))
|
||||
for _, eventID := range o.AddsStateEventIDs {
|
||||
if eventID != o.Event.EventID() {
|
||||
missingEventIDs = append(missingEventIDs, eventID)
|
||||
} else {
|
||||
addsStateEvents = append(addsStateEvents, o.Event)
|
||||
}
|
||||
}
|
||||
return addsStateEvents, missingEventIDs
|
||||
}
|
||||
|
||||
// An OutputOldRoomEvent is written when the roomserver receives an old event.
|
||||
// This will typically happen as a result of getting either missing events
|
||||
// or backfilling. Downstream components may wish to send these events to
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue