mirror of
https://github.com/hoernschen/dendrite.git
synced 2024-12-27 07:28:27 +00:00
Fix Current state appears in timeline in private history with many messages after
(#2830)
The problem was that we weren't getting enough recent events, as most of them were removed by the history visibility filter. Now we're getting all events between the given input range and re-slice the returned values after applying history visibility.
This commit is contained in:
parent
8b7bf5e7d7
commit
c62ac3d6ad
2 changed files with 12 additions and 9 deletions
|
@ -227,14 +227,10 @@ func (p *PDUStreamProvider) addRoomDeltaToResponse(
|
||||||
stateFilter *gomatrixserverlib.StateFilter,
|
stateFilter *gomatrixserverlib.StateFilter,
|
||||||
req *types.SyncRequest,
|
req *types.SyncRequest,
|
||||||
) (types.StreamPosition, error) {
|
) (types.StreamPosition, error) {
|
||||||
if delta.MembershipPos > 0 && delta.Membership == gomatrixserverlib.Leave {
|
|
||||||
// make sure we don't leak recent events after the leave event.
|
originalLimit := eventFilter.Limit
|
||||||
// TODO: History visibility makes this somewhat complex to handle correctly. For example:
|
if r.Backwards {
|
||||||
// TODO: This doesn't work for join -> leave in a single /sync request (see events prior to join).
|
eventFilter.Limit = int(r.From - r.To)
|
||||||
// TODO: This will fail on join -> leave -> sensitive msg -> join -> leave
|
|
||||||
// in a single /sync request
|
|
||||||
// This is all "okay" assuming history_visibility == "shared" which it is by default.
|
|
||||||
r.To = delta.MembershipPos
|
|
||||||
}
|
}
|
||||||
recentStreamEvents, limited, err := snapshot.RecentEvents(
|
recentStreamEvents, limited, err := snapshot.RecentEvents(
|
||||||
ctx, delta.RoomID, r,
|
ctx, delta.RoomID, r,
|
||||||
|
@ -303,6 +299,12 @@ func (p *PDUStreamProvider) addRoomDeltaToResponse(
|
||||||
logrus.WithError(err).Error("unable to apply history visibility filter")
|
logrus.WithError(err).Error("unable to apply history visibility filter")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if r.Backwards && len(events) > originalLimit {
|
||||||
|
// We're going backwards and the events are ordered chronologically, so take the last `limit` events
|
||||||
|
events = events[len(events)-originalLimit:]
|
||||||
|
limited = true
|
||||||
|
}
|
||||||
|
|
||||||
if len(delta.StateEvents) > 0 {
|
if len(delta.StateEvents) > 0 {
|
||||||
updateLatestPosition(delta.StateEvents[len(delta.StateEvents)-1].EventID())
|
updateLatestPosition(delta.StateEvents[len(delta.StateEvents)-1].EventID())
|
||||||
}
|
}
|
||||||
|
|
|
@ -757,3 +757,4 @@ Can get rooms/{roomId}/messages for a departed room (SPEC-216)
|
||||||
Local device key changes appear in /keys/changes
|
Local device key changes appear in /keys/changes
|
||||||
Can get rooms/{roomId}/members at a given point
|
Can get rooms/{roomId}/members at a given point
|
||||||
Can filter rooms/{roomId}/members
|
Can filter rooms/{roomId}/members
|
||||||
|
Current state appears in timeline in private history with many messages after
|
Loading…
Reference in a new issue