mirror of
https://github.com/element-hq/synapse.git
synced 2026-08-14 09:20:49 +00:00
Rename parse to from_json_dict
This commit is contained in:
@@ -213,7 +213,7 @@ class StrippedStateEvent:
|
||||
}
|
||||
|
||||
@staticmethod
|
||||
def parse(raw_stripped_event: Any) -> "StrippedStateEvent" | None:
|
||||
def from_json_dict(raw_stripped_event: JsonDict) -> "StrippedStateEvent" | None:
|
||||
"""
|
||||
Given a raw value from an event's `unsigned` field, attempt to parse it into a
|
||||
`StrippedStateEvent`.
|
||||
|
||||
@@ -1135,7 +1135,9 @@ class FederationHandler:
|
||||
parsed_stripped_room_state = []
|
||||
for raw_stripped_event in stripped_room_state:
|
||||
# Parse each stripped event
|
||||
parsed_stripped_event = StrippedStateEvent.parse(raw_stripped_event)
|
||||
parsed_stripped_event = StrippedStateEvent.from_json_dict(
|
||||
raw_stripped_event
|
||||
)
|
||||
if parsed_stripped_event is None:
|
||||
# Drop any invalid stripped state events as this is spec'ed and we
|
||||
# might as well save the client from dealing with anything crazy.
|
||||
@@ -1216,7 +1218,9 @@ class FederationHandler:
|
||||
includes_create_event = True
|
||||
|
||||
# Parse the stripped events to ensure it has all of the fields necessary
|
||||
parsed_stripped_event = StrippedStateEvent.parse(raw_stripped_event)
|
||||
parsed_stripped_event = StrippedStateEvent.from_json_dict(
|
||||
raw_stripped_event
|
||||
)
|
||||
if parsed_stripped_event is None:
|
||||
raise ValueError("Unable to parse as stripped event")
|
||||
parsed_stripped_room_state.append(parsed_stripped_event)
|
||||
|
||||
@@ -1617,7 +1617,7 @@ class SlidingSyncRoomLists:
|
||||
stripped_state_map = {}
|
||||
if isinstance(raw_stripped_state_events, list):
|
||||
for raw_stripped_event in raw_stripped_state_events:
|
||||
stripped_state_event = StrippedStateEvent.parse(
|
||||
stripped_state_event = StrippedStateEvent.from_json_dict(
|
||||
raw_stripped_event
|
||||
)
|
||||
if stripped_state_event is not None:
|
||||
|
||||
@@ -2251,7 +2251,9 @@ class PersistEventsStore:
|
||||
stripped_state_map: MutableStateMap[StrippedStateEvent] = {}
|
||||
if isinstance(unsigned_stripped_state_events, list):
|
||||
for raw_stripped_event in unsigned_stripped_state_events:
|
||||
stripped_state_event = StrippedStateEvent.parse(raw_stripped_event)
|
||||
stripped_state_event = StrippedStateEvent.from_json_dict(
|
||||
raw_stripped_event
|
||||
)
|
||||
if stripped_state_event is not None:
|
||||
stripped_state_map[
|
||||
(
|
||||
|
||||
Reference in New Issue
Block a user