From 783fba2d6abff2bfcc7bbf010387b724e8e2a721 Mon Sep 17 00:00:00 2001 From: Eric Eastwood Date: Wed, 6 Jan 2021 04:01:41 -0600 Subject: [PATCH] Disable IncrementalSync stuff and re-assess --- syncapi/storage/shared/syncserver.go | 38 +++++++++++++++------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/syncapi/storage/shared/syncserver.go b/syncapi/storage/shared/syncserver.go index a6b41872..16b9fd52 100644 --- a/syncapi/storage/shared/syncserver.go +++ b/syncapi/storage/shared/syncserver.go @@ -821,22 +821,25 @@ func (d *Database) getResponseWithPDUsForCompleteSync( res.Rooms.Join[roomID] = *jr } - // Extract room state and recent events for all rooms the user has left - leaveRoomIDs, err := d.CurrentRoomState.SelectRoomIDsWithMembership(ctx, txn, userID, gomatrixserverlib.Leave) - if err != nil { - return - } - // Build up a /sync response. Add leave rooms. - for _, roomID := range leaveRoomIDs { - var lr *types.LeaveResponse - lr, err = d.getLeaveResponseForCompleteSync( - ctx, txn, roomID, r, filter, device, - ) + if filter.Room.IncludeLeave { + var leaveRoomIDs []string + // Extract room state and recent events for all rooms the user has left + leaveRoomIDs, err = d.CurrentRoomState.SelectRoomIDsWithMembership(ctx, txn, userID, gomatrixserverlib.Leave) if err != nil { return } + // Build up a /sync response. Add leave rooms. + for _, roomID := range leaveRoomIDs { + var lr *types.LeaveResponse + lr, err = d.getLeaveResponseForCompleteSync( + ctx, txn, roomID, r, filter, device, + ) + if err != nil { + return + } - res.Rooms.Leave[roomID] = *lr + res.Rooms.Leave[roomID] = *lr + } } // Add peeked rooms. @@ -909,7 +912,7 @@ func (d *Database) filterStreamEventsAccordingToHistoryVisibility( } // Default to spanning the rest of the array sliceEnd := len(recentStreamEvents) - // If there is a leaveEvent, then cut all events after the person left (exclude the leave itself too) + // If there is a leaveEvent, then cut all events after the person left (exclude the leave event too) if leaveEventIndex != -1 { sliceEnd = leaveEventIndex } @@ -1225,10 +1228,11 @@ func (d *Database) addRoomDeltaToResponse( // "recentStreamEvents": fmt.Sprintf("%+v", events), // }).Info("isync addRoomDeltaToResponse before") - recentStreamEvents, limited, err = d.filterStreamEventsAccordingToHistoryVisibility(recentStreamEvents, device, limited) - if err != nil { - return err - } + // // asdf + // recentStreamEvents, limited, err = d.filterStreamEventsAccordingToHistoryVisibility(recentStreamEvents, device, limited) + // if err != nil { + // return err + // } // events = make([]somematrixevent, len(recentStreamEvents)) // for i, v := range recentStreamEvents {