synapse/synapse
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
..
_scripts Remove shebang line from module files (#10415) 2021-07-29 21:34:14 +01:00
api Add type hints to filtering classes. (#10958) 2021-10-01 07:02:32 -04:00
app Use direct references for configuration variables (part 6). (#10916) 2021-09-29 06:44:15 -04:00
appservice Use inline type hints in various other places (in synapse/) (#10380) 2021-07-15 11:02:43 +01:00
config Use direct references for configuration variables (part 6). (#10916) 2021-09-29 06:44:15 -04:00
crypto Use direct references for configuration variables (part 5). (#10897) 2021-09-24 07:25:21 -04:00
events Strip "join_authorised_via_users_server" from join events which do not need it. (#10933) 2021-09-30 11:13:59 -04:00
federation Strip "join_authorised_via_users_server" from join events which do not need it. (#10933) 2021-09-30 11:13:59 -04:00
groups Use direct references for configuration variables (part 4). (#10893) 2021-09-23 12:03:01 -04:00
handlers Consistently exclude from user_directory (#10960) 2021-10-04 11:45:51 +00:00
http Synapse 1.44.0rc1 (2021-09-29) 2021-09-29 14:23:39 +01:00
logging Use direct references for configuration variables (part 5). (#10897) 2021-09-24 07:25:21 -04:00
metrics [pyupgrade] synapse/ (#10348) 2021-07-19 15:28:05 +01:00
module_api Use direct references for some configuration variables (part 3) (#10885) 2021-09-23 07:13:34 -04:00
push Encode JSON responses on a thread in C, mk2 (#10905) 2021-09-28 09:37:58 +00:00
replication Pass str to twisted's IReactorTCP (#10895) 2021-09-30 12:51:47 +01:00
res Allow configuration of the oEmbed URLs. (#10714) 2021-08-31 18:37:07 -04:00
rest Use direct references for configuration variables (part 7). (#10959) 2021-10-04 07:18:54 -04:00
server_notices Use direct references for configuration variables (part 6). (#10916) 2021-09-29 06:44:15 -04:00
spam_checker_api Remove redundant "coding: utf-8" lines (#9786) 2021-04-14 15:34:27 +01:00
state Split event_auth.check into two parts (#10940) 2021-09-29 18:59:15 +01:00
static Display an error page during failure of fallback UIA. (#10561) 2021-08-18 08:13:35 -04:00
storage Consistently exclude from user_directory (#10960) 2021-10-04 11:45:51 +00:00
streams Remove unnecessary parentheses around tuples returned from methods (#10889) 2021-09-23 11:59:07 +01:00
util Use direct references for configuration variables (part 7). (#10959) 2021-10-04 07:18:54 -04:00
__init__.py 1.44.0rc2 2021-09-30 12:40:24 +01:00
event_auth.py Strip "join_authorised_via_users_server" from join events which do not need it. (#10933) 2021-09-30 11:13:59 -04:00
notifier.py Add type hints for event streams. (#10856) 2021-09-21 13:34:26 -04:00
python_dependencies.py Validate new m.room.power_levels events (#10232) 2021-08-26 17:07:58 +01:00
server.py Use direct references for some configuration variables (part 2) (#10812) 2021-09-15 08:34:52 -04:00
types.py Remove unnecessary parentheses around tuples returned from methods (#10889) 2021-09-23 11:59:07 +01:00
visibility.py [pyupgrade] synapse/ (#10348) 2021-07-19 15:28:05 +01:00