Simplify _update_auth_events_and_context_for_auth
move event_key calculation into _update_context_for_auth_events, since it's only used there.
This commit is contained in:
parent
963ffb60b9
commit
772d414975
|
@ -2098,11 +2098,6 @@ class FederationHandler(BaseHandler):
|
||||||
"""
|
"""
|
||||||
event_auth_events = set(event.auth_event_ids())
|
event_auth_events = set(event.auth_event_ids())
|
||||||
|
|
||||||
if event.is_state():
|
|
||||||
event_key = (event.type, event.state_key)
|
|
||||||
else:
|
|
||||||
event_key = None
|
|
||||||
|
|
||||||
# if the event's auth_events refers to events which are not in our
|
# if the event's auth_events refers to events which are not in our
|
||||||
# calculated auth_events, we need to fetch those events from somewhere.
|
# calculated auth_events, we need to fetch those events from somewhere.
|
||||||
#
|
#
|
||||||
|
@ -2231,13 +2226,13 @@ class FederationHandler(BaseHandler):
|
||||||
auth_events.update(new_state)
|
auth_events.update(new_state)
|
||||||
|
|
||||||
context = yield self._update_context_for_auth_events(
|
context = yield self._update_context_for_auth_events(
|
||||||
event, context, auth_events, event_key
|
event, context, auth_events
|
||||||
)
|
)
|
||||||
|
|
||||||
return context
|
return context
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def _update_context_for_auth_events(self, event, context, auth_events, event_key):
|
def _update_context_for_auth_events(self, event, context, auth_events):
|
||||||
"""Update the state_ids in an event context after auth event resolution,
|
"""Update the state_ids in an event context after auth event resolution,
|
||||||
storing the changes as a new state group.
|
storing the changes as a new state group.
|
||||||
|
|
||||||
|
@ -2246,18 +2241,21 @@ class FederationHandler(BaseHandler):
|
||||||
|
|
||||||
context (synapse.events.snapshot.EventContext): initial event context
|
context (synapse.events.snapshot.EventContext): initial event context
|
||||||
|
|
||||||
auth_events (dict[(str, str)->str]): Events to update in the event
|
auth_events (dict[(str, str)->EventBase]): Events to update in the event
|
||||||
context.
|
context.
|
||||||
|
|
||||||
event_key ((str, str)): (type, state_key) for the current event.
|
|
||||||
this will not be included in the current_state in the context.
|
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
Deferred[EventContext]: new event context
|
Deferred[EventContext]: new event context
|
||||||
"""
|
"""
|
||||||
|
# exclude the state key of the new event from the current_state in the context.
|
||||||
|
if event.is_state():
|
||||||
|
event_key = (event.type, event.state_key)
|
||||||
|
else:
|
||||||
|
event_key = None
|
||||||
state_updates = {
|
state_updates = {
|
||||||
k: a.event_id for k, a in iteritems(auth_events) if k != event_key
|
k: a.event_id for k, a in iteritems(auth_events) if k != event_key
|
||||||
}
|
}
|
||||||
|
|
||||||
current_state_ids = yield context.get_current_state_ids(self.store)
|
current_state_ids = yield context.get_current_state_ids(self.store)
|
||||||
current_state_ids = dict(current_state_ids)
|
current_state_ids = dict(current_state_ids)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue