* Fix /sync when we have no events
We used a since token of 0 to mean that no token was given. However, naffka
streams start at 0. This causes clients to get stuck spinning forever until an
event is sent.
This changes it so that we pass around pointers instead, with nil meaning a
since token wasn't given.
* Comment
* Fix unit tests
* Comments
* Fix typo
We should probably move the handling out from the syncapi, but that
requires the clientapi to stream the current state which it currently
doesn't. This at least stops the sync and state handling being done in
one file.
This has two benefits:
1. Using channels makes it easier to time out while waiting
2. Allows us to clean up goroutines that were waiting if we timeout the
request
* Clean roomserver consumer
* Make account data sync incremental
* Use a different name for the sync AD table
* Improved error logging
* Created missing topic in tests
* Add client API topic to tests
* Add client API topic to common
* Move data batch retrieval
* Add database index for data retrieval
* Fix typo in table name
* Fix indentation
* Save function for account data
* Fix upsert + add empty routes and function
* Save account data
* Retrieval functions
* Implement retrieval in /sync
* Fix arrays not correctly initialised
* Merge account data retrieval functions
* Request DB only once per request
* Initialise array
* Fix comment
- Renamed `clientapi/auth/types` to `clientapi/auth/authtypes` for the same
horrible namespace clashing reasons as `storage`.
- Factored out `makeAPI` to `common`.
- Added in `makeAuthAPI`.
The logic required to populate the right bits of `RoomData` tends towards
the complete `/sync` response struct, so just use the actual response struct
and save the hassle of mapping between the two. It may not make much difference
in its current form, but the next PR will make use of this.
This PR has no functional changes.
This is only 'mostly' correct currently, because what should be no-op dupe
joins will actually trigger the entire room state to be re-sent.
Bizarrely, it's significantly easier to just do that than work out if we should,
and there are no client-visible effects to doing so, so we just do it for now.
* Split out notifying /sync requests and calculating sync responses
The logic for notifying /sync requests is about to get really
complicated as we optimise when to wake up requests, so split
out that code into a separate struct to isolate it and make
it easier to unit test.