Commit Graph

162 Commits

Author SHA1 Message Date
Erik Johnston 2f041e6dbb Add comment that common/specific fields are immutable 2026-05-29 11:10:13 +01:00
Erik Johnston ddea42625d Update missing auth events error 2026-05-29 11:07:39 +01:00
Erik Johnston 93a1185ba4 Remove Python redaction in favour of Rust
Rather than keeping two implementations about
2026-05-28 10:59:31 +01:00
Erik Johnston cb6906e3a5 Correctly redact m.relates_to
We didn't keep `m.relates_to` field in the latest room versions.
2026-05-28 10:58:56 +01:00
Erik Johnston 00e8108714 Handle the case of a very large duration 2026-05-27 16:59:28 +01:00
Erik Johnston 0105b520bc Validate that the room ID does actually start with a '!' 2026-05-27 16:58:19 +01:00
Erik Johnston 77a2348615 Transfer existing and previous docstrings to events.pyi 2026-05-27 16:39:34 +01:00
Erik Johnston 06b933698f Add docstring to 'other_fields' 2026-05-27 16:08:10 +01:00
Erik Johnston a89a1c0563 Expand FormattedEvent type 2026-05-27 16:06:05 +01:00
Erik Johnston 39c7501a1a Fixup FormattedEvent docstring 2026-05-27 16:04:15 +01:00
Erik Johnston 66fdb410f1 'Kept seperate from common/specific fields...' 2026-05-27 15:59:59 +01:00
Erik Johnston 114f94a2a1 Use PyAssertionError 2026-05-27 15:56:28 +01:00
Erik Johnston a3082b76be Ensure room_id is absent for create event 2026-05-27 15:54:19 +01:00
Erik Johnston ee733ae2f6 Correctly handle room_id/state_key being null
These should either be absent or strings. We cannot use `Option` as that
does not differentiate between `null` and an absent field.
2026-05-27 15:51:03 +01:00
Erik Johnston 8fd10e4143 s/test_room_id_for_create_event/test_room_id_for_create_event_format_v4/ 2026-05-27 13:38:25 +01:00
Erik Johnston ae3a03fc4f Sanity check state_key is None instead of some empty string 2026-05-27 13:37:22 +01:00
Erik Johnston 9fa851d7f5 Comment on why state_key_attr 2026-05-27 13:31:59 +01:00
Erik Johnston feaa364f86 Rename bad_key to unknown_key 2026-05-27 13:14:57 +01:00
Erik Johnston d6258ff227 Make test_redact_missing_type clearer 2026-05-27 13:13:42 +01:00
Erik Johnston 925f5a1294 Handle MSC4242 in redact 2026-05-27 12:57:30 +01:00
Erik Johnston 15462d1d44 Lint 2026-05-27 12:57:16 +01:00
Erik Johnston f1ae164ab9 Remove redacted_because TODO 2026-05-27 12:53:46 +01:00
Erik Johnston 51ace0f588 Don't check PDU size in compute_reference_hash 2026-05-27 12:52:45 +01:00
Erik Johnston 1479a94ee7 Pop AGE_TS when redacting as well 2026-05-27 12:47:45 +01:00
Erik Johnston ecf8e8c869 Comment why type_ 2026-05-27 12:05:15 +01:00
Erik Johnston 309f826d21 Note that third-party modules rely on deprecated functions 2026-05-27 12:04:04 +01:00
Erik Johnston ee669251c1 Clean up .sticky_duration() 2026-05-27 12:02:50 +01:00
Erik Johnston ffe6c8b430 Add MSC4354_STICKY constant 2026-05-27 11:51:03 +01:00
Erik Johnston 025f1a479e Fix tests 2026-05-21 14:56:48 +01:00
Erik Johnston c9e9d76e86 Make MAX_DURATION a SynapseDuration 2026-05-21 14:45:52 +01:00
Erik Johnston b99fd7329d s/debug_assert/ensure 2026-05-21 14:37:30 +01:00
Erik Johnston 1bbb0332bd Drop SimpleAuthPrevEvents 2026-05-21 14:36:19 +01:00
Erik Johnston 894d223132 Mention where get_templated_pdu_json is used 2026-05-21 14:34:55 +01:00
Erik Johnston aae2de1cf0 Update get_dict docstring 2026-05-21 14:32:11 +01:00
Erik Johnston 24e7f8516a Rename to parsed_event 2026-05-21 14:31:26 +01:00
Erik Johnston fc65b1d5bc Add room version to error 2026-05-21 14:27:14 +01:00
Erik Johnston 27e312ddaf Make JsonObject.object private 2026-05-21 14:26:02 +01:00
Erik Johnston 8e6e29cf1a Fix MAX_PDU_SIZE_BYTES 2026-05-21 14:15:02 +01:00
Erik Johnston e82ebe17b2 Small refactor to ensure we call 'validate' for all formats 2026-05-21 14:14:29 +01:00
Erik Johnston 69c8d226b8 Ensure we don't have stray auth_events or event_id fields unexpectedly set 2026-05-21 14:10:51 +01:00
Erik Johnston 71151640b2 Update error for auth_event_ids 2026-05-21 14:02:10 +01:00
Erik Johnston f5f7e7c729 Convert get_room_id_for_optional_room_id into match 2026-05-21 13:56:08 +01:00
Erik Johnston d4801f78a7 Docstring for type_state_key_tuple 2026-05-21 13:46:10 +01:00
Erik Johnston d7a8dc5e27 Comment which fields are mutable and immutable 2026-05-21 13:43:59 +01:00
Erik Johnston cdc09df65a s/on-the-wire/over-the-wire 2026-05-21 13:38:53 +01:00
Erik Johnston 6135aaca11 Add Event pyclass to Rust
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, etc) 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`.
2026-05-15 15:59:55 +01:00
Erik Johnston e028519772 Add helpers and visibility for the upcoming Event port
Small prerequisites for porting the Python EventBase hierarchy to Rust:

- duration: make `from_milliseconds` const and add an `IntoPyObject` impl
  for owned `SynapseDuration`, so the new Rust `Event.sticky_duration()`
  can return one directly to Python.
- internal_metadata: rename `copy()` to `deep_copy()` (matching the new
  naming used by the rest of the events module) and make `new()` callable
  from sibling modules.
- json_object: expose `object` as a `pub` field and add a `get_field`
  helper so the new Event class can read from it without going through
  Python.
- signatures, unsigned: add `deep_copy()` methods so the new Event class
  can implement its own deep-copy.
2026-05-15 15:59:03 +01:00
Erik Johnston ace8447037 Tidy up Rust RoomVersion structs (#19766)
This is in prep for using the room versions more from Rust.

Main changes:
- Change it so each room version is defined as a delta to the last one.
This is a cosmetic change that makes it easier to ensure the room
version definitions are correct (as they're defined as deltas from
previous versions).
- Move constants to `RoomVersion` constants, like `RoomVersion::V1`, for
convenience.
- Change visibility of various attributes.
2026-05-14 11:21:00 +01:00
Olivier 'reivilibre 1b0622fa99 Merge branch 'release-v1.153' into develop 2026-05-13 13:10:18 +01:00
Erik Johnston 5efeac44b2 Handle arbitrary sized integers in unsigned. (#19769)
Handle arbitrary sized integers in `unsigned` (and other Rust objects
that use `serde_json::Value`)
2026-05-13 11:28:06 +01:00