user_directory.py 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. # Copyright 2017 New Vector Ltd
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. from ._base import Config
  15. class UserDirectoryConfig(Config):
  16. """User Directory Configuration
  17. Configuration for the behaviour of the /user_directory API
  18. """
  19. section = "userdirectory"
  20. def read_config(self, config, **kwargs):
  21. user_directory_config = config.get("user_directory") or {}
  22. self.user_directory_search_enabled = user_directory_config.get("enabled", True)
  23. self.user_directory_search_all_users = user_directory_config.get(
  24. "search_all_users", False
  25. )
  26. self.user_directory_search_prefer_local_users = user_directory_config.get(
  27. "prefer_local_users", False
  28. )
  29. def generate_config_section(self, config_dir_path, server_name, **kwargs):
  30. return """
  31. # User Directory configuration
  32. #
  33. user_directory:
  34. # Defines whether users can search the user directory. If false then
  35. # empty responses are returned to all queries. Defaults to true.
  36. #
  37. # Uncomment to disable the user directory.
  38. #
  39. #enabled: false
  40. # Defines whether to search all users visible to your HS when searching
  41. # the user directory. If false, search results will only contain users
  42. # visible in public rooms and users sharing a room with the requester.
  43. # Defaults to false.
  44. #
  45. # NB. If you set this to true, and the last time the user_directory search
  46. # indexes were (re)built was before Synapse 1.44, you'll have to
  47. # rebuild the indexes in order to search through all known users.
  48. # These indexes are built the first time Synapse starts; admins can
  49. # manually trigger a rebuild following the instructions at
  50. # https://matrix-org.github.io/synapse/latest/user_directory.html
  51. #
  52. # Uncomment to return search results containing all known users, even if that
  53. # user does not share a room with the requester.
  54. #
  55. #search_all_users: true
  56. # Defines whether to prefer local users in search query results.
  57. # If True, local users are more likely to appear above remote users
  58. # when searching the user directory. Defaults to false.
  59. #
  60. # Uncomment to prefer local over remote users in user directory search
  61. # results.
  62. #
  63. #prefer_local_users: true
  64. """