mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-06-04 17:28:49 -04:00
Factor out a separate EventContext.for_outlier
(#10883)
Constructing an EventContext for an outlier is actually really simple, and there's no sense in going via an `async` method in the `StateHandler`. This also means that we can resolve a bunch of FIXMEs.
This commit is contained in:
parent
f78b68a96b
commit
26f2bfedbf
5 changed files with 21 additions and 44 deletions
|
@ -80,9 +80,7 @@ class EventContext:
|
|||
|
||||
(type, state_key) -> event_id
|
||||
|
||||
FIXME: what is this for an outlier? it seems ill-defined. It seems like
|
||||
it could be either {}, or the state we were given by the remote
|
||||
server, depending on $THINGS
|
||||
For an outlier, this is {}
|
||||
|
||||
Note that this is a private attribute: it should be accessed via
|
||||
``get_current_state_ids``. _AsyncEventContext impl calculates this
|
||||
|
@ -96,7 +94,7 @@ class EventContext:
|
|||
|
||||
(type, state_key) -> event_id
|
||||
|
||||
FIXME: again, what is this for an outlier?
|
||||
For an outlier, this is {}
|
||||
|
||||
As with _current_state_ids, this is a private attribute. It should be
|
||||
accessed via get_prev_state_ids.
|
||||
|
@ -130,6 +128,14 @@ class EventContext:
|
|||
delta_ids=delta_ids,
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def for_outlier():
|
||||
"""Return an EventContext instance suitable for persisting an outlier event"""
|
||||
return EventContext(
|
||||
current_state_ids={},
|
||||
prev_state_ids={},
|
||||
)
|
||||
|
||||
async def serialize(self, event: EventBase, store: "DataStore") -> dict:
|
||||
"""Converts self to a type that can be serialized as JSON, and then
|
||||
deserialized by `deserialize`
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue