user_directory.py 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. def read_config(self, config):
  21. self.user_directory_search_all_users = False
  22. user_directory_config = config.get("user_directory", None)
  23. if user_directory_config:
  24. self.user_directory_search_all_users = (
  25. user_directory_config.get("search_all_users", False)
  26. )
  27. def default_config(self, config_dir_path, server_name, **kwargs):
  28. return """
  29. # User Directory configuration
  30. #
  31. # 'search_all_users' defines whether to search all users visible to your HS
  32. # when searching the user directory, rather than limiting to users visible
  33. # in public rooms. Defaults to false. If you set it True, you'll have to run
  34. # UPDATE user_directory_stream_pos SET stream_id = NULL;
  35. # on your database to tell it to rebuild the user_directory search indexes.
  36. #
  37. #user_directory:
  38. # search_all_users: false
  39. """