forked-synapse/tests
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
..
api Use direct references for configuration variables (part 6). (#10916) 2021-09-29 06:44:15 -04:00
app Use direct references for configuration variables (part 4). (#10893) 2021-09-23 12:03:01 -04:00
appservice Fix errors in Synapse logs from unit tests. (#10939) 2021-09-30 11:03:29 -04:00
config Use direct references for configuration variables (part 7). (#10959) 2021-10-04 07:18:54 -04:00
crypto Rewrite the KeyRing (#10035) 2021-06-02 16:37:59 +01: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 Fix errors in Synapse logs from unit tests. (#10939) 2021-09-30 11:03:29 -04:00
handlers Consistently exclude from user_directory (#10960) 2021-10-04 11:45:51 +00:00
http Use direct references for configuration variables (part 6). (#10916) 2021-09-29 06:44:15 -04:00
logging Add reactor to SynapseRequest and fix up types. (#10868) 2021-09-24 11:01:25 +01:00
module_api Fix errors in Synapse logs from unit tests. (#10939) 2021-09-30 11:03:29 -04:00
push Synapse 1.42.0rc1 (2021-09-01) 2021-09-01 14:58:14 +01:00
replication type-hint HomeserverTestcase.setup_test_homeserver (#10961) 2021-10-01 12:22:47 +01:00
rest Consistently exclude from user_directory (#10960) 2021-10-04 11:45:51 +00:00
scripts Remove redundant "coding: utf-8" lines (#9786) 2021-04-14 15:34:27 +01:00
server_notices Use direct references for configuration variables (part 6). (#10916) 2021-09-29 06:44:15 -04:00
state Update the MSC3083 support to verify if joins are from an authorized server. (#10254) 2021-07-26 12:17:00 -04:00
storage Consistently exclude from user_directory (#10960) 2021-10-04 11:45:51 +00:00
test_utils Create a constant for a small png image in tests. (#10834) 2021-09-16 12:01:14 -04:00
util Use direct references for configuration variables (part 4). (#10893) 2021-09-23 12:03:01 -04:00
__init__.py Remove redundant "coding: utf-8" lines (#9786) 2021-04-14 15:34:27 +01:00
server.py Pass str to twisted's IReactorTCP (#10895) 2021-09-30 12:51:47 +01:00
test_distributor.py Remove redundant "coding: utf-8" lines (#9786) 2021-04-14 15:34:27 +01:00
test_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
test_federation.py Inline _check_event_auth for outliers (#10926) 2021-09-28 15:25:07 +01:00
test_mau.py Use direct references for configuration variables (part 6). (#10916) 2021-09-29 06:44:15 -04:00
test_metrics.py Remove redundant "coding: utf-8" lines (#9786) 2021-04-14 15:34:27 +01:00
test_phone_home.py Remove redundant "coding: utf-8" lines (#9786) 2021-04-14 15:34:27 +01:00
test_preview.py Support underscores (in addition to hyphens) for charset detection. (#10410) 2021-07-27 17:29:42 +00:00
test_server.py Add reactor to SynapseRequest and fix up types. (#10868) 2021-09-24 11:01:25 +01:00
test_state.py Remove unnecessary parentheses around tuples returned from methods (#10889) 2021-09-23 11:59:07 +01:00
test_terms_auth.py Flatten the synapse.rest.client package (#10600) 2021-08-17 11:57:58 +00:00
test_test_utils.py Remove redundant "coding: utf-8" lines (#9786) 2021-04-14 15:34:27 +01:00
test_types.py [pyupgrade] tests/ (#10347) 2021-07-13 11:43:15 +01:00
test_visibility.py Remove redundant "coding: utf-8" lines (#9786) 2021-04-14 15:34:27 +01:00
unittest.py Consistently exclude from user_directory (#10960) 2021-10-04 11:45:51 +00:00
utils.py Remove unnecessary parentheses around tuples returned from methods (#10889) 2021-09-23 11:59:07 +01:00