@@ -24,41 +24,46 @@ class UserDirectoryConfig(Config):
2424 section = "userdirectory"
2525
2626 def read_config (self , config , ** kwargs ):
27- self .user_directory_search_enabled = True
28- self .user_directory_search_all_users = False
29- self .user_directory_search_prefer_local_users = False
30- user_directory_config = config .get ("user_directory" , None )
31- if user_directory_config :
32- self .user_directory_search_enabled = user_directory_config .get (
33- "enabled" , True
34- )
35- self .user_directory_search_all_users = user_directory_config .get (
36- "search_all_users" , False
37- )
38- self .user_directory_search_prefer_local_users = user_directory_config .get (
39- "prefer_local_users" , False
40- )
27+ user_directory_config = config .get ("user_directory" ) or {}
28+ self .user_directory_search_enabled = user_directory_config .get ("enabled" , True )
29+ self .user_directory_search_all_users = user_directory_config .get (
30+ "search_all_users" , False
31+ )
32+ self .user_directory_search_prefer_local_users = user_directory_config .get (
33+ "prefer_local_users" , False
34+ )
4135
4236 def generate_config_section (self , config_dir_path , server_name , ** kwargs ):
4337 return """
4438 # User Directory configuration
4539 #
46- # 'enabled' defines whether users can search the user directory. If
47- # false then empty responses are returned to all queries. Defaults to
48- # true.
49- #
50- # 'search_all_users' defines whether to search all users visible to your HS
51- # when searching the user directory, rather than limiting to users visible
52- # in public rooms. Defaults to false. If you set it True, you'll have to
53- # rebuild the user_directory search indexes, see
54- # https://github.com/matrix-org/synapse/blob/master/docs/user_directory.md
55- #
56- # 'prefer_local_users' defines whether to prioritise local users in
57- # search query results. If True, local users are more likely to appear above
58- # remote users when searching the user directory. Defaults to false.
59- #
60- #user_directory:
61- # enabled: true
62- # search_all_users: false
63- # prefer_local_users: false
40+ user_directory:
41+ # Defines whether users can search the user directory. If false then
42+ # empty responses are returned to all queries. Defaults to true.
43+ #
44+ # Uncomment to disable the user directory.
45+ #
46+ #enabled: false
47+
48+ # Defines whether to search all users visible to your HS when searching
49+ # the user directory, rather than limiting to users visible in public
50+ # rooms. Defaults to false.
51+ #
52+ # If you set it true, you'll have to rebuild the user_directory search
53+ # indexes, see:
54+ # https://github.com/matrix-org/synapse/blob/master/docs/user_directory.md
55+ #
56+ # Uncomment to return search results containing all known users, even if that
57+ # user does not share a room with the requester.
58+ #
59+ #search_all_users: true
60+
61+ # Defines whether to prefer local users in search query results.
62+ # If True, local users are more likely to appear above remote users
63+ # when searching the user directory. Defaults to false.
64+ #
65+ # Uncomment to prefer local over remote users in user directory search
66+ # results.
67+ #
68+ #prefer_local_users: true
6469 """
0 commit comments