Remove redacted_because from internal unsigned.#19581
Open
erikjohnston wants to merge 10 commits intodevelopfrom
Open
Remove redacted_because from internal unsigned.#19581erikjohnston wants to merge 10 commits intodevelopfrom
redacted_because from internal unsigned.#19581erikjohnston wants to merge 10 commits intodevelopfrom
Conversation
c2d73b6 to
7d90b4c
Compare
erikjohnston
commented
Mar 17, 2026
| as_client_event=True, | ||
| # If this is an invite or a knock membership event, and we're interested | ||
| # in this user, then include any stripped state alongside the event. | ||
| include_stripped_room_state=True, |
Member
Author
There was a problem hiding this comment.
The check for membership is superfluous as we only include stripped state for invites and knocks anyway, so the change here is that we include stripped state even if the appservice is not interested in the user. Which I think is fine.
The reason to batch things up is so that we more efficiently fetch redactions from the DB.
7d90b4c to
b99fb4e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is a simplification so that
unsignedonly includes "simple" values, to make it easier to port to Rust.Reviewable commit-by-commit
Summary:
Add
recheckcolumn toredactionstableA new boolean
recheckcolumn (default true) is added to theredactionstable. This captures whether a redaction needs its sender domain checked at read time — required for room v3+ where redactions are accepted speculatively and later validated. When persisting a new redaction,recheckis set directly fromevent.internal_metadata.need_to_check_redaction().It's fine if initially we recheck all redactions, as it only results in a little more CPU overhead (as we always pull out the redaction event regardless).
Backfill
recheckvia background updateA background update (
redactions_recheck) backfills the new column for existing rows by readingrecheck_redactionfrom each event'sinternal_metadataJSON. This avoids loading full event objects by readingevent_jsondirectly via a SQL JOIN.Don't fetch confirmed redaction events from the DB
Previously, when loading events, Synapse recursively fetched all redaction events regardless of whether they needed domain rechecking. Now
_fetch_event_rowsreads therecheckcolumn and splits redactions into two lists:unconfirmed_redactions— need fetching and domain validationconfirmed_redactions— already validated, applied directly without fetching the eventThis avoids unnecessary DB reads for the common case of already-confirmed redactions.
Move
redacted_becausepopulation toEventClientSerializerPreviously,
redacted_because(the full redaction event object) was stored inevent.unsignedat DB fetch time, coupling storage-layer code to client serialization concerns. This is removed from_maybe_redact_event_rowand moved intoEventClientSerializer.serialize_event, which fetches the redaction event on demand. The storage layer now only setsunsigned["redacted_by"](the redaction event ID).Always use
EventClientSerializerThe standalone
serialize_eventfunction was made private (_serialize_event). All external callers —rest/client/room.py,rest/admin/events.py, appservice/api.py, andtests— were updated to useEventClientSerializer.serialize_event/serialize_events, ensuringredacted_becauseis always populated correctly via the serializer.Batch-fetch redaction events in
serialize_eventsserialize_eventsnow collects allredacted_byIDs from the event batch upfront and fetches them in a singleget_eventscall, passing the result as aredaction_mapto eachserialize_eventcall. This reduces N individual DB round-trips to one when serializing a batch of events that includes redacted events.