anonymousland-synapse/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 Use direct references for some configuration variables (part 3) (#10885) 2021-09-23 07:13:34 -04:00
__init__.py Remove redundant "coding: utf-8" lines (#9786) 2021-04-14 15:34:27 +01:00
_base.py Require type hints in the handlers module. (#10831) 2021-09-20 08:56:23 -04:00
account_data.py Add type hints for event streams. (#10856) 2021-09-21 13:34:26 -04:00
account_validity.py Use direct references for some configuration variables (part 3) (#10885) 2021-09-23 07:13:34 -04:00
admin.py Use inline type hints in handlers/ and rest/. (#10382) 2021-07-16 18:22:36 +01:00
appservice.py Use direct references for some configuration variables (part 3) (#10885) 2021-09-23 07:13:34 -04:00
auth.py Use direct references for configuration variables (part 4). (#10893) 2021-09-23 12:03:01 -04:00
cas.py Use direct references for some configuration variables (part 3) (#10885) 2021-09-23 07:13:34 -04:00
deactivate_account.py Fix reactivated users not being added to the user directory (#10782) 2021-09-23 12:02:13 +00:00
device.py Require type hints in the handlers module. (#10831) 2021-09-20 08:56:23 -04:00
devicemessage.py Use direct references for some configuration variables (#10798) 2021-09-13 13:07:12 -04:00
directory.py Use inline type hints in handlers/ and rest/. (#10382) 2021-07-16 18:22:36 +01:00
e2e_keys.py Require type hints in the handlers module. (#10831) 2021-09-20 08:56:23 -04:00
e2e_room_keys.py Remove redundant "coding: utf-8" lines (#9786) 2021-04-14 15:34:27 +01:00
event_auth.py Require type hints in the handlers module. (#10831) 2021-09-20 08:56:23 -04:00
events.py Use inline type hints in handlers/ and rest/. (#10382) 2021-07-16 18:22:36 +01:00
federation_event.py Factor out common code for persisting fetched auth events (#10896) 2021-09-24 11:56:33 +01:00
federation.py Remove unnecessary parentheses around tuples returned from methods (#10889) 2021-09-23 11:59:07 +01:00
groups_local.py Require type hints in the handlers module. (#10831) 2021-09-20 08:56:23 -04:00
identity.py Use direct references for some configuration variables (part 3) (#10885) 2021-09-23 07:13:34 -04:00
initial_sync.py Add type hints for event streams. (#10856) 2021-09-21 13:34:26 -04:00
message.py Use direct references for some configuration variables (part 3) (#10885) 2021-09-23 07:13:34 -04:00
oidc.py Use direct references for configuration variables (part 4). (#10893) 2021-09-23 12:03:01 -04:00
pagination.py Require type hints in the handlers module. (#10831) 2021-09-20 08:56:23 -04:00
password_policy.py Use direct references for some configuration variables (part 3) (#10885) 2021-09-23 07:13:34 -04:00
presence.py Add type hints for event streams. (#10856) 2021-09-21 13:34:26 -04:00
profile.py Use direct references for configuration variables (part 4). (#10893) 2021-09-23 12:03:01 -04:00
read_marker.py Use direct references for some configuration variables (#10798) 2021-09-13 13:07:12 -04:00
receipts.py Remove unnecessary parentheses around tuples returned from methods (#10889) 2021-09-23 11:59:07 +01:00
register.py Use direct references for some configuration variables (part 3) (#10885) 2021-09-23 07:13:34 -04:00
room_list.py Require type hints in the handlers module. (#10831) 2021-09-20 08:56:23 -04:00
room_member_worker.py Implement knock feature (#6739) 2021-06-09 19:39:51 +01:00
room_member.py Allow sending a membership event to unban a user (#10807) 2021-09-21 10:23:34 +00:00
room_summary.py Remove unnecessary parentheses around tuples returned from methods (#10889) 2021-09-23 11:59:07 +01:00
room.py Remove unnecessary parentheses around tuples returned from methods (#10889) 2021-09-23 11:59:07 +01:00
saml.py Require type hints in the handlers module. (#10831) 2021-09-20 08:56:23 -04:00
search.py Use inline type hints in handlers/ and rest/. (#10382) 2021-07-16 18:22:36 +01:00
send_email.py Require type hints in the handlers module. (#10831) 2021-09-20 08:56:23 -04:00
set_password.py Remove redundant "coding: utf-8" lines (#9786) 2021-04-14 15:34:27 +01:00
sso.py Require type hints in the handlers module. (#10831) 2021-09-20 08:56:23 -04:00
state_deltas.py Easy refactors of the user directory (#10789) 2021-09-10 10:54:38 +01:00
stats.py Require type hints in the handlers module. (#10831) 2021-09-20 08:56:23 -04:00
sync.py Add type hints for event streams. (#10856) 2021-09-21 13:34:26 -04:00
typing.py Remove unnecessary parentheses around tuples returned from methods (#10889) 2021-09-23 11:59:07 +01:00
user_directory.py Require type hints in the handlers module. (#10831) 2021-09-20 08:56:23 -04:00