From 6dd18094b76c2ede06ec401e320949c2a986bdb5 Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Wed, 20 Jan 2021 16:31:39 +0000 Subject: [PATCH] Don't leak anything for left rooms until history vis works --- syncapi/streams/stream_pdu.go | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/syncapi/streams/stream_pdu.go b/syncapi/streams/stream_pdu.go index 39c31be1..143da3a4 100644 --- a/syncapi/streams/stream_pdu.go +++ b/syncapi/streams/stream_pdu.go @@ -305,6 +305,7 @@ func (p *PDUStreamProvider) getJoinResponseForCompleteSync( return jr, nil } +// nolint:unparam func (p *PDUStreamProvider) getLeaveResponseForCompleteSync( ctx context.Context, roomID string, @@ -313,18 +314,20 @@ func (p *PDUStreamProvider) getLeaveResponseForCompleteSync( eventFilter *gomatrixserverlib.RoomEventFilter, device *userapi.Device, ) (lr *types.LeaveResponse, err error) { - recentEvents, stateEvents, prevBatch, limited, err := p.getResponseForCompleteSync( - ctx, roomID, r, stateFilter, eventFilter, device, - ) - if err != nil { - return nil, fmt.Errorf("p.getResponseForCompleteSync: %w", err) - } + /* + recentEvents, stateEvents, prevBatch, limited, err := p.getResponseForCompleteSync( + ctx, roomID, r, stateFilter, eventFilter, device, + ) + if err != nil { + return nil, fmt.Errorf("p.getResponseForCompleteSync: %w", err) + } + */ lr = types.NewLeaveResponse() - lr.Timeline.PrevBatch = prevBatch - lr.Timeline.Events = gomatrixserverlib.HeaderedToClientEvents(recentEvents, gomatrixserverlib.FormatSync) - lr.Timeline.Limited = limited - lr.State.Events = gomatrixserverlib.HeaderedToClientEvents(stateEvents, gomatrixserverlib.FormatSync) + //lr.Timeline.PrevBatch = prevBatch + //lr.Timeline.Events = gomatrixserverlib.HeaderedToClientEvents(recentEvents, gomatrixserverlib.FormatSync) + //lr.Timeline.Limited = limited + //lr.State.Events = gomatrixserverlib.HeaderedToClientEvents(stateEvents, gomatrixserverlib.FormatSync) return lr, nil } @@ -398,6 +401,11 @@ func (p *PDUStreamProvider) filterStreamEventsAccordingToHistoryVisibility( return recentStreamEvents[sliceStart:sliceEnd], limited } +// removeDuplicates takes a set of state events and timeline events and +// builds up a new set of state events. The returned state set will +// exclude any state events that appear in the timeline, so that the +// returned sync response doesn't duplicate them across both the state +// and timeline keys. func removeDuplicates(stateEvents, recentEvents []*gomatrixserverlib.HeaderedEvent) []*gomatrixserverlib.HeaderedEvent { timeline := map[string]struct{}{} for _, event := range recentEvents {