mirror of
https://github.com/matrix-org/dendrite.git
synced 2024-11-29 09:41:57 -06:00
Truncate recentStreamEvents
before working out which event IDs to exclude from stateEvents
(#2281)
This commit is contained in:
parent
69268fc48e
commit
fc0bdf5d88
|
@ -271,22 +271,6 @@ func (p *PDUStreamProvider) getJoinResponseForCompleteSync(
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the event IDs of the stream events we fetched. There's no point in us
|
|
||||||
var excludingEventIDs []string
|
|
||||||
if !wantFullState {
|
|
||||||
excludingEventIDs = make([]string, 0, len(recentStreamEvents))
|
|
||||||
for _, event := range recentStreamEvents {
|
|
||||||
if event.StateKey() != nil {
|
|
||||||
excludingEventIDs = append(excludingEventIDs, event.EventID())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
stateEvents, err := p.DB.CurrentState(ctx, roomID, stateFilter, excludingEventIDs)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO FIXME: We don't fully implement history visibility yet. To avoid leaking events which the
|
// TODO FIXME: We don't fully implement history visibility yet. To avoid leaking events which the
|
||||||
// user shouldn't see, we check the recent events and remove any prior to the join event of the user
|
// user shouldn't see, we check the recent events and remove any prior to the join event of the user
|
||||||
// which is equiv to history_visibility: joined
|
// which is equiv to history_visibility: joined
|
||||||
|
@ -314,6 +298,25 @@ func (p *PDUStreamProvider) getJoinResponseForCompleteSync(
|
||||||
limited = false // so clients know not to try to backpaginate
|
limited = false // so clients know not to try to backpaginate
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Work our way through the timeline events and pick out the event IDs
|
||||||
|
// of any state events that appear in the timeline. We'll specifically
|
||||||
|
// exclude them at the next step, so that we don't get duplicate state
|
||||||
|
// events in both `recentStreamEvents` and `stateEvents`.
|
||||||
|
var excludingEventIDs []string
|
||||||
|
if !wantFullState {
|
||||||
|
excludingEventIDs = make([]string, 0, len(recentStreamEvents))
|
||||||
|
for _, event := range recentStreamEvents {
|
||||||
|
if event.StateKey() != nil {
|
||||||
|
excludingEventIDs = append(excludingEventIDs, event.EventID())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stateEvents, err := p.DB.CurrentState(ctx, roomID, stateFilter, excludingEventIDs)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// Retrieve the backward topology position, i.e. the position of the
|
// Retrieve the backward topology position, i.e. the position of the
|
||||||
// oldest event in the room's topology.
|
// oldest event in the room's topology.
|
||||||
var prevBatch *types.TopologyToken
|
var prevBatch *types.TopologyToken
|
||||||
|
|
Loading…
Reference in a new issue