forked-synapse/synapse/handlers
David Robertson f7b034a24b
Consistently exclude from user_directory (#10960)
* Introduce `should_include_local_users_in_dir`

We exclude three kinds of local users from the user_directory tables. At
present we don't consistently exclude all three in the same places. This
commit introduces a new function to gather those exclusion conditions
together. Because we have to handle local and remote users in different
ways, I've made that function only consider the case of remote users.
It's the caller's responsibility to make the local versus remote
distinction clear and correct.

A test fixup is required. The test now hits a path which makes db
queries against the users table. The expected rows were missing, because
we were using a dummy user that hadn't actually been registered.

We also add new test cases to covert the exclusion logic.

----

By my reading this makes these changes:

* When an app service user registers or changes their profile, they will
  _not_ be added to the user directory. (Previously only support and
  deactivated users were excluded). This is consistent with the logic that
  rebuilds the user directory. See also [the discussion
  here](https://github.com/matrix-org/synapse/pull/10914#discussion_r716859548).
* When rebuilding the directory, exclude support and disabled users from
  room sharing tables. Previously only appservice users were excluded.
* Exclude all three categories of local users when rebuilding the
  directory. Previously `_populate_user_directory_process_users` didn't do
  any exclusion.

Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>
2021-10-04 11:45:51 +00:00
..
ui_auth Use direct references for configuration variables (part 7). (#10959) 2021-10-04 07:18:54 -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 7). (#10959) 2021-10-04 07:18:54 -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 direct references for configuration variables (part 6). (#10916) 2021-09-29 06:44:15 -04: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 Split event_auth.check into two parts (#10940) 2021-09-29 18:59:15 +01:00
events.py Use inline type hints in handlers/ and rest/. (#10382) 2021-07-16 18:22:36 +01:00
federation_event.py Split event_auth.check into two parts (#10940) 2021-09-29 18:59:15 +01:00
federation.py Strip "join_authorised_via_users_server" from join events which do not need it. (#10933) 2021-09-30 11:13:59 -04: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 configuration variables (part 7). (#10959) 2021-10-04 07:18:54 -04:00
initial_sync.py Add type hints for event streams. (#10856) 2021-09-21 13:34:26 -04:00
message.py Synapse 1.44.0rc2 (2021-09-30) 2021-09-30 13:40:24 +01:00
oidc.py Use direct references for configuration variables (part 4). (#10893) 2021-09-23 12:03:01 -04:00
pagination.py Use direct references for configuration variables (part 6). (#10916) 2021-09-29 06:44:15 -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 Fix issue causing sending presence to ASes to fail (due to incomplete type annotations) (#10944) 2021-09-30 11:06:47 +01:00
profile.py Use direct references for configuration variables (part 7). (#10959) 2021-10-04 07:18:54 -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 configuration variables (part 7). (#10959) 2021-10-04 07:18:54 -04:00
room_list.py Use direct references for configuration variables (part 5). (#10897) 2021-09-24 07:25:21 -04:00
room_member_worker.py Implement knock feature (#6739) 2021-06-09 19:39:51 +01:00
room_member.py Use direct references for configuration variables (part 7). (#10959) 2021-10-04 07:18:54 -04:00
room_summary.py Remove unnecessary parentheses around tuples returned from methods (#10889) 2021-09-23 11:59:07 +01:00
room.py Split event_auth.check into two parts (#10940) 2021-09-29 18:59:15 +01:00
saml.py Use direct references for configuration variables (part 5). (#10897) 2021-09-24 07:25:21 -04:00
search.py Use direct references for configuration variables (part 6). (#10916) 2021-09-29 06:44:15 -04:00
send_email.py Pass str to twisted's IReactorTCP (#10895) 2021-09-30 12:51:47 +01:00
set_password.py Remove redundant "coding: utf-8" lines (#9786) 2021-04-14 15:34:27 +01:00
sso.py Use direct references for configuration variables (part 5). (#10897) 2021-09-24 07:25:21 -04:00
state_deltas.py Easy refactors of the user directory (#10789) 2021-09-10 10:54:38 +01:00
stats.py Use direct references for configuration variables (part 5). (#10897) 2021-09-24 07:25:21 -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 Consistently exclude from user_directory (#10960) 2021-10-04 11:45:51 +00:00