user_directory.py 2.7 KB

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