Skip to content

fix(sync): apply senders/contains_url filters, gate historical leaves by include_leave#232

Merged
sufforest merged 2 commits into
mainfrom
wzy/sync-filter-include-leave-senders-url
Jul 3, 2026
Merged

fix(sync): apply senders/contains_url filters, gate historical leaves by include_leave#232
sufforest merged 2 commits into
mainfrom
wzy/sync-filter-include-leave-senders-url

Conversation

@sufforest

@sufforest sufforest commented Jul 3, 2026

Copy link
Copy Markdown
Owner

Three sync-filter compliance gaps, verified against the filter definitions and continuwuity/Synapse behavior.

senders allow-list + contains_url — the room timeline/state filters only applied types/not_types/not_senders, silently ignoring the senders allow-list and contains_url. Factored a shared RoomEventFilter predicate and added both:

  • not_senders is checked before senders, so a sender in both is excluded (spec precedence). An empty senders: [] excludes everything (distinct from absent).
  • contains_url keeps events whose content.url is a string (matching Synapse: null/non-string count as "no url").
  • The state filter now also reaches MSC4222 state_after (built internally under the stable key, renamed for the client afterwards). Element opts into MSC4222, so filtering only /state/events was a no-op there — this fixes types/not_types too, which had the same blind spot.

include_leave (spec default false) was ignored — an initial /sync returned every room the user had ever left. Corrected semantics:

  • A room whose membership changed within the sync window (the leave itself) is always surfaced, so a client learns of a leave on the incremental sync that spans it.
  • A historical left room is surfaced only on a full view of the account — an initial or full_state sync — and only when include_leave is set. include_leave does not re-surface an already-reported leave on later incremental syncs (Complement's TestOlderLeftRoomsNotInLeaveSection).

Known limitation (documented in code): the timeline is trimmed to limit upstream, then filtered, so a highly selective predicate can return fewer than limit matches even when more exist earlier — matching Synapse would require pushing the predicate into the timeline read.

Tests: senders allow-list + not_senders precedence + empty-list; contains_url true/false/omitted and null/non-string url; state filtering under state_after; and include_leave gating (initial excludes historical, include_leave surfaces them on a full view, an in-window leave is always surfaced, and a historical leave is not re-surfaced on later incremental syncs).

sufforest added 2 commits July 3, 2026 06:29
… by include_leave

Three sync-filter gaps:

- Room timeline/state filters ignored the `senders` allow-list and
  `contains_url` — only types/not_types/not_senders applied. Share one
  RoomEventFilter predicate and add both (not_senders keeps precedence over
  senders; contains_url matches a string url, Synapse-style). The state
  filter now also reaches MSC4222 `state_after`, where Element carries its
  state, so it was previously a no-op there for the primary client.
- `include_leave` (spec default false) was ignored: an initial sync returned
  every room the user had ever left. Historical left rooms now appear only
  when the filter opts in, while a room left within the sync window is still
  always surfaced so the client learns of the leave.
…remental sync

The first cut gated left rooms on `newly_left || include_leave`, which made a
room left long ago reappear in the leave section on every incremental sync
when include_leave was set — breaking Complement's
TestOlderLeftRoomsNotInLeaveSection. A left room now surfaces on an
incremental sync only when the membership changed within the window; an
initial or full-state sync includes historical left rooms exactly when
include_leave is set.
@sufforest sufforest merged commit 4a13d02 into main Jul 3, 2026
11 checks passed
@sufforest sufforest deleted the wzy/sync-filter-include-leave-senders-url branch July 3, 2026 14:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant