Grapevine is a Matrix homeserver, forked from Conduit 0.7.0
Find a file
Benjamin Lee 8d09a7e490 don't return extra member count or e2ee device updates from sync
Previously, we were returning redundant member count updates or encrypted
device updates from the /sync endpoint in some cases. The extra member
count updates are spec-compliant, but unnecessary, while the extra
encrypted device updates violate the spec.

The refactor necessary to fix this bug is also necessary to support
filtering on state events in sync.

Details:

Joined room incremental sync needs to examine state events for four
purposes:

 1. determining whether we need to return an update to room member counts
 2. determining the set of left/joined devices for encrypted rooms
    (returned in `device_lists`)
 3. returning state events to the client (in `rooms.joined.*.state`)
 4. tracking which member events we have sent to the client, so they can
    be omitted on future requests when lazy-loading is enabled.

The state events that we need to examine for the first two cases is member
events in the delta between `since` and the end of `timeline`. For the
second two cases, we need the delta between `since` and the start of
`timeline`, plus contextual member events for any senders that occur in
`timeline`. The second list is subject to filtering, while the first is
not.

Before this change, we were using the same set of state events that we are
returning to the client (cases 3/4) to do the analysis for cases 1/2.
In a compliant implementation, this would result in us missing some
relevant member events in 1/2 in addition to seeing redundant member
events. In current grapevine this is not the case because the set of
events that we return to the client is always a superset of the set that
is needed for cases 1/2. This is because we don't support filtering, and
we have an existing bug[1] where we are returning the delta between
`since` and the end of `timeline` rather than the start.

[1]: https://gitlab.computer.surgery/matrix/grapevine-fork/-/issues/5

Fixing this is necessary to implement filtering because otherwise
we would start missing some member events for member count or encrypted
device updates if the relevant member events are rejected by the filter.
This would be much worse than our current behavior.
2024-05-20 21:13:13 +00:00
bin build and cache all packages and CI dependencies 2024-05-14 20:08:37 -07:00
nix add conduit compat mode 2024-05-14 20:21:51 -07:00
src don't return extra member count or e2ee device updates from sync 2024-05-20 21:13:13 +00:00
.envrc allow loading env vars from .env if it exists 2024-05-14 20:08:37 -07:00
.gitignore allow loading env vars from .env if it exists 2024-05-14 20:08:37 -07:00
.gitlab-ci.yml build and cache all packages and CI dependencies 2024-05-14 20:08:37 -07:00
Cargo.lock prevent xss via user-uploaded media 2024-05-19 21:05:02 -07:00
Cargo.toml prevent xss via user-uploaded media 2024-05-19 21:05:02 -07:00
clippy.toml enable doc_markdown lint 2024-05-14 16:34:10 -07:00
default.nix feat: support non-flake users 2024-02-01 19:19:56 -08:00
engage.toml run clippy for no, default, and all features 2024-04-30 21:54:56 -07:00
flake.lock update rocksdb 2024-05-16 21:50:31 -07:00
flake.nix update rocksdb 2024-05-16 21:50:31 -07:00
LICENSE.md convert license to markdown 2024-04-30 21:54:56 -07:00
rust-toolchain.toml update rust toolchain 2024-01-25 21:44:40 -08:00
rustfmt.toml enable error_on_line_overflow and fix errors 2024-05-16 19:11:40 -07:00