diff --git a/syncapi/storage/shared/sync_pdu.go b/syncapi/storage/shared/sync_pdu.go index 26ecbe3c..2e9a2ba2 100644 --- a/syncapi/storage/shared/sync_pdu.go +++ b/syncapi/storage/shared/sync_pdu.go @@ -27,7 +27,8 @@ func (d *Database) PDUCompleteSync( defer sqlutil.EndTransactionWithCheck(txn, &succeeded, &err) for _, roomID := range joinedRoomIDs { - jr, err := d.getJoinResponseForCompleteSync( + var jr *types.JoinResponse + jr, err = d.getJoinResponseForCompleteSync( ctx, txn, roomID, r, stateFilter, eventFilter, req.WantFullState, req.Device, ) if err != nil { @@ -38,6 +39,24 @@ func (d *Database) PDUCompleteSync( req.Rooms[roomID] = gomatrixserverlib.Join } + peeks, err := d.Peeks.SelectPeeksInRange(ctx, txn, req.Device.UserID, req.Device.ID, r) + if err != nil { + return fmt.Errorf("d.Peeks.SelectPeeksInRange: %w", err) + } + + for _, peek := range peeks { + if !peek.Deleted { + var jr *types.JoinResponse + jr, err = d.getJoinResponseForCompleteSync( + ctx, txn, peek.RoomID, r, stateFilter, eventFilter, req.WantFullState, req.Device, + ) + if err != nil { + return fmt.Errorf("d.getJoinResponseForCompleteSync: %w", err) + } + req.Response.Rooms.Peek[peek.RoomID] = *jr + } + } + succeeded = true return nil } diff --git a/syncapi/streams/stream_pdu.go b/syncapi/streams/stream_pdu.go index a333c1b0..ecb7f1df 100644 --- a/syncapi/streams/stream_pdu.go +++ b/syncapi/streams/stream_pdu.go @@ -47,15 +47,6 @@ func (p *PDUStreamProvider) CompleteSync( return from } - // Add peeked rooms. - /* - peeks, err := p.DB.PeeksInRange(ctx, req.Device.UserID, req.Device.ID, r) - if err != nil { - req.Log.WithError(err).Error("p.DB.PeeksInRange failed") - return from - } - */ - stateFilter := req.Filter.Room.State eventFilter := req.Filter.Room.Timeline @@ -64,24 +55,6 @@ func (p *PDUStreamProvider) CompleteSync( return from } - /* - for _, peek := range peeks { - p.queue(func() { - if !peek.Deleted { - var jr *types.JoinResponse - jr, err = p.getJoinResponseForCompleteSync( - ctx, peek.RoomID, r, &stateFilter, &eventFilter, req.WantFullState, req.Device, - ) - if err != nil { - req.Log.WithError(err).Error("p.getJoinResponseForCompleteSync failed") - return - } - req.Response.Rooms.Peek[peek.RoomID] = *jr - } - }) - } - */ - return to }