mirror of
https://github.com/hoernschen/dendrite.git
synced 2025-07-30 04:52:46 +00:00
only send new events to RS; add tests for /state_ids and /event (#1011)
* only send new events to RS; add tests for /state_ids and /event * Review comments: send in auth event order * Ignore order of state events for this test as RespState.Events is non-deterministic
This commit is contained in:
parent
1294852270
commit
3b98535dc5
3 changed files with 183 additions and 23 deletions
|
@ -52,9 +52,10 @@ func (c *RoomserverProducer) SendEvents(
|
|||
}
|
||||
|
||||
// SendEventWithState writes an event with KindNew to the roomserver input log
|
||||
// with the state at the event as KindOutlier before it.
|
||||
// with the state at the event as KindOutlier before it. Will not send any event that is
|
||||
// marked as `true` in haveEventIDs
|
||||
func (c *RoomserverProducer) SendEventWithState(
|
||||
ctx context.Context, state *gomatrixserverlib.RespState, event gomatrixserverlib.HeaderedEvent,
|
||||
ctx context.Context, state *gomatrixserverlib.RespState, event gomatrixserverlib.HeaderedEvent, haveEventIDs map[string]bool,
|
||||
) error {
|
||||
outliers, err := state.Events()
|
||||
if err != nil {
|
||||
|
@ -63,6 +64,9 @@ func (c *RoomserverProducer) SendEventWithState(
|
|||
|
||||
var ires []api.InputRoomEvent
|
||||
for _, outlier := range outliers {
|
||||
if haveEventIDs[outlier.EventID()] {
|
||||
continue
|
||||
}
|
||||
ires = append(ires, api.InputRoomEvent{
|
||||
Kind: api.KindOutlier,
|
||||
Event: outlier.Headered(event.RoomVersion),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue