29 Commits

Author SHA1 Message Date
Kegan Dougal
8b6f48a24b Add more logging to response lines 2023-07-31 10:24:36 +01:00
David Robertson
da1b6fee28
Make range array of size 2; inline clamp function 2023-04-11 13:02:46 +01:00
Kegan Dougal
773bb6b3e5 extensions refactor: remove updateWillReturnResponse
It was a very unclear boolean with unclear semantics, when what
we really meant was "if this is a room update and there is room
data included in this response, send back extension data".
2023-02-08 16:33:52 +00:00
Kegan Dougal
ca6ceb28da BREAKING: Change the API to refer to lists by keys not index positions
This provides more flexibility to refer to lists as well as delete them.
2022-12-20 13:32:39 +00:00
Kegan Dougal
aa28df161c Rename package -> github.com/matrix-org/sliding-sync 2022-12-15 11:08:50 +00:00
Kegan Dougal
0d3157d610 Add support for txn_id in request/response
Missing buffering
2022-08-03 15:33:56 +01:00
Kegan Dougal
7f8eaee701 Add untested code for fetching all rooms in a list with slow_get_all_rooms set 2022-05-31 17:32:41 +01:00
Kegan Dougal
20587e6dd0 Remove 'room_id' field from Room objects as it is redundant 2022-05-27 15:23:31 +01:00
Kegan Dougal
9e0295267d Remove the UPDATE command
It is not required now that `ops` only relate to rooms changing positions.
2022-05-27 13:47:14 +01:00
Kegan Dougal
6eea9a824b 1/2: Major refactor to send union'd room responses
- Complete the implementation and get UTs passing
    - Get timelines/security integration tests passing
    - For now, leaving out theh rest of the integration tests

    Still TODO:
    - Add in the remaining integration tests
    - We need to remember if we have sent initial room data down
      a connection. For now we just check if the room was in the window
      prior to resorting, then decide based on that if we should send
      initial vs delta updates. However, this falls down when a room
      is both a subscription and in a list, as when it comes into the
      window we add the sub to the builder, which then causes an initial
      response even though we know they have it already due to the direct
      room subscription.
    - Refactor resort / moveRoom - it's horrible currently.
    - Remove UPDATE.
    - Remove getDeltaRoomData and replace with just an 'updateFields' or
      equiv, as we will sometimes set deltas only to send initials later on.
2022-05-27 09:33:25 +01:00
Kegan Dougal
854a6e25d9 Refactor IncludedRoomIDsInOps 2022-05-26 17:01:45 +01:00
Kegan Dougal
d9ee2b2a69 3/?: Add room_id and room_ids to ops in prep to remove room and rooms 2022-05-25 12:52:56 +01:00
Kegan Dougal
a82615978b 2/? : Refactor API shape to be closer to the current MSC
Specifically:
 - Remove top-level `ops`, and replace with `lists`.
 - Remove list indexes from `ops`, and rely on contextual location information.
 - Remove top-level `counts` and instead embed them into each list contextually.
 - Refactor connstate to reflect new API shape.

Still to do:
 - Remove `rooms` / `room` from the op response, and bundle it into the
   top-level `rooms`.
 - Remove `UPDATE` op.
 - Add `room_id` / `room_ids` field to ops to let clients know which rooms each op relates to.
2022-05-25 11:36:30 +01:00
Kegan Dougal
735f638a11 1/?: Rename room_subscriptions to rooms in prep for new API shape 2022-05-24 10:35:23 +01:00
Kegan Dougal
3ecef2062e feature: Support account_data extension
Along with a battery of tests to make sure we give account data only
for rooms being tracked in the sliding lists, unless it's global in
which case we just send it on.
2022-03-24 19:38:55 +00:00
Kegan Dougal
4a03b12287 client/server: set 'initial' flag on a per-room basis and use it when rendering
Previously the 'initial' flag was set on the entire response which was pointless
as the client can detect this by the presence/absence of `?pos=`.

Instead, move the `initial` flag to be present on the Room object, so clients know
when to replace or update their databases. Use this to fix a bug where the timeline
would show incorrectly when clicking on rooms due to appending to the timeline when
the room subscription data was collected.
2022-02-24 16:48:39 +00:00
Kegan Dougal
8f27160a88 Make pos a string and not an int 2022-01-04 15:32:50 +00:00
Kegan Dougal
fa823d6e86 Add support for the initial flag 2021-12-22 16:04:00 +00:00
Kegan Dougal
0e021eb560 Pass to-device messages through to the client
- Treat to-device messages as opaque JSON blobs
- Add basic integration test to ensure the messages make it from v2 to v3.
2021-12-14 11:51:47 +00:00
Kegan Dougal
60a53870c8 Add extensions package and glue it into the sync3 handler
Extensions will be the main way to compartmentalise additional
/sync functionality beyond the baseline of a sliding window
and room subscriptions. Things like presence, to-device messages,
receipts, OTK counts and device lists, typing, etc can all live
as optional opt-in extensions to the core protocol.

The intention is that extensions can lean on the baseline
functionality to get information like "which rooms are present
in the sliding window" and "which rooms are directly subscribed to"
in order to aid their calculations. For example, a typing extension
may have a flag to only show typing notifications in directly
subscribed rooms (e.g rooms whose timelines are visible). To-device
extensions by comparison will just be a simple 'fetch more events'
API as it cannot make use of visible rooms in any meaningful way
as metadata is encrypted, but will make use of an explicit `since`
token to avoid implicit ACKs which plague sync v2. Presence extensions
may only load presence status for users who are joined to the
sliding window of rooms rather than all rooms. This functionality
can be provided without bogging down the logic with sliding window
handling.
2021-12-13 18:22:41 +00:00
Kegan Dougal
2cd90bca1c Flesh out to-device API
Naming in harmony with https://github.com/matrix-org/matrix-doc/issues/1898
2021-12-13 15:27:02 +00:00
Kegan Dougal
d1e9409694 Implement multiple list support
Untested but seems to work empirically as integration tests pass and
the test jig doesn't explode. Needs refactoring once tests land.
2021-11-09 16:57:57 +00:00
Kegan Dougal
101d06d996 API change: allow multiple lists in requests 2021-11-08 10:16:32 +00:00
Kegan Dougal
91653ce3d1 Add integration test jig and a basic test
- Add sync3.Response UnmarshalJSON() so we can dynamically make the
  correct single/range op.
- Create sub-structs for sync2.Response to make inline embedding
  easier in tests.
2021-10-25 18:03:32 +01:00
Kegan Dougal
93aad63f1b Basic room subscription support, with basic tests 2021-10-05 17:04:28 +01:00
Kegan Dougal
e20a8ad067 Move synclive to sync3 2021-10-05 16:22:02 +01:00
Kegan Dougal
5b4b1a10ed Glue to_device stuff into the v3 handler, refactor to prevent import cycles 2021-08-03 12:06:09 +01:00
Kegan Dougal
90dceee6f6 Add V2DataReceiver interface and indirect via SyncV3Handler
This allows us to notify the Notifier as well as store the data
in the database. Reshuffle where streams live (it's a sync v3 concept).
2021-07-23 15:39:41 +01:00
Kegan Dougal
f8563c0c1b Flesh out request/response glue code 2021-07-21 15:03:09 +01:00