summary refs log tree commit diff
path: root/synapse/events/builder.py
diff options
context:
space:
mode:
authorErik Johnston <erikj@element.io>2024-01-08 14:06:48 +0000
committerGitHub <noreply@github.com>2024-01-08 14:06:48 +0000
commit5d3850b0384c7da286031b169d9a37320b6783ea (patch)
tree5300ed0d40538d25f32cf8666966907a60e70165 /synapse/events/builder.py
parentFix linting (#16780) (diff)
downloadsynapse-5d3850b0384c7da286031b169d9a37320b6783ea.tar.xz
Port `EventInternalMetadata` class to Rust (#16782)
There are a couple of things we need to be careful of here:

1. The current python code does no validation when loading from the DB,
so we need to be careful to ignore such errors (at least on jki.re there
are some old events with internal metadata fields of the wrong type).
2. We want to be memory efficient, as we often have many hundreds of
thousands of events in the cache at a time.

---------

Co-authored-by: Quentin Gliech <quenting@element.io>
Diffstat (limited to 'synapse/events/builder.py')
-rw-r--r--synapse/events/builder.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/synapse/events/builder.py b/synapse/events/builder.py
index ae7092daaa..f32449c7da 100644
--- a/synapse/events/builder.py
+++ b/synapse/events/builder.py
@@ -31,9 +31,10 @@ from synapse.api.room_versions import (
 )
 from synapse.crypto.event_signing import add_hashes_and_signatures
 from synapse.event_auth import auth_types_for_event
-from synapse.events import EventBase, _EventInternalMetadata, make_event_from_dict
+from synapse.events import EventBase, make_event_from_dict
 from synapse.state import StateHandler
 from synapse.storage.databases.main import DataStore
+from synapse.synapse_rust.events import EventInternalMetadata
 from synapse.types import EventID, JsonDict, StrCollection
 from synapse.types.state import StateFilter
 from synapse.util import Clock
@@ -93,8 +94,8 @@ class EventBuilder:
     _redacts: Optional[str] = None
     _origin_server_ts: Optional[int] = None
 
-    internal_metadata: _EventInternalMetadata = attr.Factory(
-        lambda: _EventInternalMetadata({})
+    internal_metadata: EventInternalMetadata = attr.Factory(
+        lambda: EventInternalMetadata({})
     )
 
     @property