MatrixSynapse/synapse/handlers
Richard van der Hoff 85551b7a85
Factor out common code for persisting fetched auth events (#10896)
* Factor more stuff out of `_get_events_and_persist`

It turns out that the event-sorting algorithm in `_get_events_and_persist` is
also useful in other circumstances. Here we move the current
`_auth_and_persist_fetched_events` to `_auth_and_persist_fetched_events_inner`,
and then factor the sorting part out to `_auth_and_persist_fetched_events`.

* `_get_remote_auth_chain_for_event`: remove redundant `outlier` assignment

`get_event_auth` returns events with the outlier flag already set, so this is
redundant (though we need to update a test where `get_event_auth` is mocked).

* `_get_remote_auth_chain_for_event`: move existing-event tests earlier

Move a couple of tests outside the loop. This is a bit inefficient for now, but
a future commit will make it better. It should be functionally identical.

* `_get_remote_auth_chain_for_event`: use `_auth_and_persist_fetched_events`

We can use the same codepath for persisting the events fetched as part of an
auth chain as for those fetched individually by `_get_events_and_persist` for
building the state at a backwards extremity.

* `_get_remote_auth_chain_for_event`: use a dict for efficiency

`_auth_and_persist_fetched_events` sorts the events itself, so we no longer
need to care about maintaining the ordering from `get_event_auth` (and no
longer need to sort by depth in `get_event_auth`).

That means that we can use a map, making it easier to filter out events we
already have, etc.

* changelog

* `_auth_and_persist_fetched_events`: improve docstring
2021-09-24 11:56:33 +01:00
..
ui_auth
__init__.py
_base.py
account_data.py
account_validity.py
admin.py
appservice.py
auth.py
cas.py
deactivate_account.py
device.py
devicemessage.py
directory.py
e2e_keys.py
e2e_room_keys.py
event_auth.py
events.py
federation.py
federation_event.py Factor out common code for persisting fetched auth events (#10896) 2021-09-24 11:56:33 +01:00
groups_local.py
identity.py
initial_sync.py
message.py
oidc.py
pagination.py
password_policy.py
presence.py
profile.py
read_marker.py
receipts.py
register.py
room.py
room_list.py
room_member.py
room_member_worker.py
room_summary.py
saml.py Require type hints in the handlers module. (#10831) 2021-09-20 08:56:23 -04:00
search.py
send_email.py
set_password.py
sso.py
state_deltas.py
stats.py
sync.py
typing.py
user_directory.py