mirror of
https://github.com/element-hq/synapse.git
synced 2026-05-13 17:13:11 +00:00
583e8fb2a1
Adds a single `Event` Rust pyclass that replaces the Python EventBase /
FrozenEventV{1,2,3,4,VMSC4242} hierarchy. The class is added but not yet
wired into Python — callers continue to use the existing Python classes
in this commit; the migration follows in the next commit.
The internals use an `FormattedEvent` over
`EventFormatV{1,2V3,4,VMSC4242}` structs sharing an `EventCommonFields`.
Format-specific behaviour (prev_event_ids, auth_event_ids, room_id
derivation for v12 create events, prev_state_events for MSC4242) is
encapsulated per variant. Event IDs are computed in the constructor for
v3+ formats; v1/v2 use the `event_id` field as-is.
Two supporting Rust modules are added at the same time:
- `events::constants` — string constants for event types, top-level
fields, and per-event-type content fields, used to keep the redaction
rules and field accessors readable.
- `events::utils` — `redact()`, `compute_event_reference_hash()`, and
`calculate_event_id()`, ported from `synapse.crypto.event_signing` /
`synapse.events.utils` and exhaustively tested per room version.
The .pyi stub uses `JsonMapping` for the `content` getter and exposes
`prev_state_events` as a `@property` returning `StrSequence`. The
matching `#[getter]` is in place on the Rust side from the start.