mirror of
https://mau.dev/maunium/synapse.git
synced 2024-10-01 01:36:05 -04:00
Hide new users from the user directory if enabled in the server config.
This commit is contained in:
parent
9cce175bf0
commit
d331119758
@ -178,6 +178,12 @@ class ServerConfig(Config):
|
||||
# events with profile information that differ from the target's global profile.
|
||||
self.allow_per_room_profiles = config.get("allow_per_room_profiles", True)
|
||||
|
||||
# Whether to show the users on this homeserver in the user directory. Defaults to
|
||||
# True.
|
||||
self.show_users_in_user_directory = config.get(
|
||||
"show_users_in_user_directory", True,
|
||||
)
|
||||
|
||||
self.listeners = []
|
||||
for listener in config.get("listeners", []):
|
||||
if not isinstance(listener.get("port", None), int):
|
||||
@ -577,6 +583,11 @@ class ServerConfig(Config):
|
||||
# Defaults to 'true'.
|
||||
#
|
||||
#allow_per_room_profiles: false
|
||||
|
||||
# Whether to show the users on this homeserver in the user directory. Defaults to
|
||||
# 'true'.
|
||||
#
|
||||
#show_users_in_user_directory: false
|
||||
""" % locals()
|
||||
|
||||
def read_arguments(self, args):
|
||||
|
@ -74,6 +74,8 @@ class RegistrationHandler(BaseHandler):
|
||||
)
|
||||
self._server_notices_mxid = hs.config.server_notices_mxid
|
||||
|
||||
self._show_in_user_directory = self.hs.show_users_in_user_directory
|
||||
|
||||
if hs.config.worker_app:
|
||||
self._register_client = ReplicationRegisterServlet.make_client(hs)
|
||||
self._register_device_client = (
|
||||
@ -289,6 +291,14 @@ class RegistrationHandler(BaseHandler):
|
||||
user_id, threepid_dict, None, False,
|
||||
)
|
||||
|
||||
# Prevent the new user from showing up in the user directory if the server
|
||||
# mandates it.
|
||||
if self._show_in_user_directory:
|
||||
yield self.store.add_account_data_for_user(
|
||||
user_id, "im.vector.hide_profile", {'hide_profile': True},
|
||||
)
|
||||
yield self.profile_handler.set_active(user, False, True)
|
||||
|
||||
defer.returnValue((user_id, token))
|
||||
|
||||
@defer.inlineCallbacks
|
||||
|
Loading…
Reference in New Issue
Block a user