Update onOldRoomEvent

This commit is contained in:
Neil Alexander 2021-01-11 09:42:06 +00:00
parent 0fbebecd41
commit c1bc3df1e0
No known key found for this signature in database
GPG key ID: A02A2019A2BB0944
2 changed files with 20 additions and 10 deletions

View file

@ -207,10 +207,10 @@ func (s *OutputRoomEventConsumer) onOldRoomEvent(
ctx, ctx,
ev, ev,
[]*gomatrixserverlib.HeaderedEvent{}, []*gomatrixserverlib.HeaderedEvent{},
[]string{}, // adds no state []string{}, // adds no state
[]string{}, // removes no state []string{}, // removes no state
nil, // no transaction nil, // no transaction
ev.StateKey() != nil, // exclude from sync? true, // exclude from sync?
) )
if err != nil { if err != nil {
// panic rather than continue with an inconsistent database // panic rather than continue with an inconsistent database
@ -221,13 +221,8 @@ func (s *OutputRoomEventConsumer) onOldRoomEvent(
return nil return nil
} }
if pduPos, err = s.notifyJoinedPeeks(ctx, ev, pduPos); err != nil {
log.WithError(err).Errorf("Failed to notifyJoinedPeeks for PDU pos %d", pduPos)
return err
}
s.pduStream.Advance(pduPos) s.pduStream.Advance(pduPos)
s.notifier.OnNewEvent(ev, ev.RoomID(), nil, types.StreamingToken{PDUPosition: pduPos}) s.notifier.OnOldEvent(ev, ev.RoomID(), nil, types.StreamingToken{PDUPosition: pduPos})
return nil return nil
} }

View file

@ -124,6 +124,21 @@ func (n *Notifier) OnNewEvent(
} }
} }
// OnOldEvent is called when the sync API receives an "old" event, e.g.
// because it was pulled in by get_missing_events or similar. We need
// to update the stream position, but we don't bother waking up any
// clients because the event will be stored as excluded from sync anyway.
func (n *Notifier) OnOldEvent(
ev *gomatrixserverlib.HeaderedEvent, roomID string, userIDs []string,
posUpdate types.StreamingToken,
) {
n.streamLock.Lock()
defer n.streamLock.Unlock()
n.currPos.ApplyUpdates(posUpdate)
n.removeEmptyUserStreams()
}
func (n *Notifier) OnNewAccountData( func (n *Notifier) OnNewAccountData(
userID string, posUpdate types.StreamingToken, userID string, posUpdate types.StreamingToken,
) { ) {