* Rename "make" to "makeAPI" and factor out some more common code into it
Naming a function the same as a go builtin function seems like a bad
idea. Also move the call to `NewJSONRequestHander` inside the function
rather than calling it everywhere.
* Fix typo
- `s/Server/OutputRoomEvent/` in `consumers` to accurately reflect what is being consumed.
- `s/set/userIDSet/` in `notifier.go` for clarity.
- Removed lying comments.
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.
- Test data for the sync server is now in its own file.
- Rejig the sync server tests to support multiple /sync requests and corresponding
assertions.
- Fixed a minor bug which resulted in state events to appear twice in /sync
responses when syncing without a `since` parameter.
* 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.
This has the following known shortcomings:
- It doesn't handle missing events not in the from/to range.
- It doesn't order events in the timeline correctly.
- It doesn't handle invited/left rooms at all.
- There is no intelligent wakeup logic: events for Bob will wake up Alice's stream.