Use direct references for configuration variables (part 5). (#10897)
This commit is contained in:
parent
85551b7a85
commit
bb7fdd821b
|
@ -0,0 +1 @@
|
||||||
|
Use direct references to config flags.
|
|
@ -88,8 +88,8 @@ def start_worker_reactor(appname, config, run_command=reactor.run):
|
||||||
appname,
|
appname,
|
||||||
soft_file_limit=config.soft_file_limit,
|
soft_file_limit=config.soft_file_limit,
|
||||||
gc_thresholds=config.gc_thresholds,
|
gc_thresholds=config.gc_thresholds,
|
||||||
pid_file=config.worker_pid_file,
|
pid_file=config.worker.worker_pid_file,
|
||||||
daemonize=config.worker_daemonize,
|
daemonize=config.worker.worker_daemonize,
|
||||||
print_pidfile=config.print_pidfile,
|
print_pidfile=config.print_pidfile,
|
||||||
logger=logger,
|
logger=logger,
|
||||||
run_command=run_command,
|
run_command=run_command,
|
||||||
|
|
|
@ -186,9 +186,9 @@ def start(config_options):
|
||||||
config.worker.worker_app = "synapse.app.admin_cmd"
|
config.worker.worker_app = "synapse.app.admin_cmd"
|
||||||
|
|
||||||
if (
|
if (
|
||||||
not config.worker_daemonize
|
not config.worker.worker_daemonize
|
||||||
and not config.worker_log_file
|
and not config.worker.worker_log_file
|
||||||
and not config.worker_log_config
|
and not config.worker.worker_log_config
|
||||||
):
|
):
|
||||||
# Since we're meant to be run as a "command" let's not redirect stdio
|
# Since we're meant to be run as a "command" let's not redirect stdio
|
||||||
# unless we've actually set log config.
|
# unless we've actually set log config.
|
||||||
|
|
|
@ -140,7 +140,7 @@ class KeyUploadServlet(RestServlet):
|
||||||
self.auth = hs.get_auth()
|
self.auth = hs.get_auth()
|
||||||
self.store = hs.get_datastore()
|
self.store = hs.get_datastore()
|
||||||
self.http_client = hs.get_simple_http_client()
|
self.http_client = hs.get_simple_http_client()
|
||||||
self.main_uri = hs.config.worker_main_http_uri
|
self.main_uri = hs.config.worker.worker_main_http_uri
|
||||||
|
|
||||||
async def on_POST(self, request: Request, device_id: Optional[str]):
|
async def on_POST(self, request: Request, device_id: Optional[str]):
|
||||||
requester = await self.auth.get_user_by_req(request, allow_guest=True)
|
requester = await self.auth.get_user_by_req(request, allow_guest=True)
|
||||||
|
@ -321,7 +321,7 @@ class GenericWorkerServer(HomeServer):
|
||||||
elif name == "federation":
|
elif name == "federation":
|
||||||
resources.update({FEDERATION_PREFIX: TransportLayerServer(self)})
|
resources.update({FEDERATION_PREFIX: TransportLayerServer(self)})
|
||||||
elif name == "media":
|
elif name == "media":
|
||||||
if self.config.can_load_media_repo:
|
if self.config.media.can_load_media_repo:
|
||||||
media_repo = self.get_media_repository_resource()
|
media_repo = self.get_media_repository_resource()
|
||||||
|
|
||||||
# We need to serve the admin servlets for media on the
|
# We need to serve the admin servlets for media on the
|
||||||
|
@ -384,7 +384,7 @@ class GenericWorkerServer(HomeServer):
|
||||||
logger.info("Synapse worker now listening on port %d", port)
|
logger.info("Synapse worker now listening on port %d", port)
|
||||||
|
|
||||||
def start_listening(self):
|
def start_listening(self):
|
||||||
for listener in self.config.worker_listeners:
|
for listener in self.config.worker.worker_listeners:
|
||||||
if listener.type == "http":
|
if listener.type == "http":
|
||||||
self._listen_http(listener)
|
self._listen_http(listener)
|
||||||
elif listener.type == "manhole":
|
elif listener.type == "manhole":
|
||||||
|
|
|
@ -234,7 +234,7 @@ class SynapseHomeServer(HomeServer):
|
||||||
)
|
)
|
||||||
|
|
||||||
if name in ["media", "federation", "client"]:
|
if name in ["media", "federation", "client"]:
|
||||||
if self.config.enable_media_repo:
|
if self.config.media.enable_media_repo:
|
||||||
media_repo = self.get_media_repository_resource()
|
media_repo = self.get_media_repository_resource()
|
||||||
resources.update(
|
resources.update(
|
||||||
{MEDIA_PREFIX: media_repo, LEGACY_MEDIA_PREFIX: media_repo}
|
{MEDIA_PREFIX: media_repo, LEGACY_MEDIA_PREFIX: media_repo}
|
||||||
|
|
|
@ -322,7 +322,9 @@ def setup_logging(
|
||||||
|
|
||||||
"""
|
"""
|
||||||
log_config_path = (
|
log_config_path = (
|
||||||
config.worker_log_config if use_worker_options else config.logging.log_config
|
config.worker.worker_log_config
|
||||||
|
if use_worker_options
|
||||||
|
else config.logging.log_config
|
||||||
)
|
)
|
||||||
|
|
||||||
# Perform one-time logging configuration.
|
# Perform one-time logging configuration.
|
||||||
|
|
|
@ -74,8 +74,8 @@ class ServerContextFactory(ContextFactory):
|
||||||
context.set_options(
|
context.set_options(
|
||||||
SSL.OP_NO_SSLv2 | SSL.OP_NO_SSLv3 | SSL.OP_NO_TLSv1 | SSL.OP_NO_TLSv1_1
|
SSL.OP_NO_SSLv2 | SSL.OP_NO_SSLv3 | SSL.OP_NO_TLSv1 | SSL.OP_NO_TLSv1_1
|
||||||
)
|
)
|
||||||
context.use_certificate_chain_file(config.tls_certificate_file)
|
context.use_certificate_chain_file(config.tls.tls_certificate_file)
|
||||||
context.use_privatekey(config.tls_private_key)
|
context.use_privatekey(config.tls.tls_private_key)
|
||||||
|
|
||||||
# https://hynek.me/articles/hardening-your-web-servers-ssl-ciphers/
|
# https://hynek.me/articles/hardening-your-web-servers-ssl-ciphers/
|
||||||
context.set_cipher_list(
|
context.set_cipher_list(
|
||||||
|
|
|
@ -78,7 +78,7 @@ def load_legacy_spam_checkers(hs: "synapse.server.HomeServer"):
|
||||||
"""
|
"""
|
||||||
spam_checkers: List[Any] = []
|
spam_checkers: List[Any] = []
|
||||||
api = hs.get_module_api()
|
api = hs.get_module_api()
|
||||||
for module, config in hs.config.spam_checkers:
|
for module, config in hs.config.spamchecker.spam_checkers:
|
||||||
# Older spam checkers don't accept the `api` argument, so we
|
# Older spam checkers don't accept the `api` argument, so we
|
||||||
# try and detect support.
|
# try and detect support.
|
||||||
spam_args = inspect.getfullargspec(module)
|
spam_args = inspect.getfullargspec(module)
|
||||||
|
|
|
@ -42,10 +42,10 @@ def load_legacy_third_party_event_rules(hs: "HomeServer"):
|
||||||
"""Wrapper that loads a third party event rules module configured using the old
|
"""Wrapper that loads a third party event rules module configured using the old
|
||||||
configuration, and registers the hooks they implement.
|
configuration, and registers the hooks they implement.
|
||||||
"""
|
"""
|
||||||
if hs.config.third_party_event_rules is None:
|
if hs.config.thirdpartyrules.third_party_event_rules is None:
|
||||||
return
|
return
|
||||||
|
|
||||||
module, config = hs.config.third_party_event_rules
|
module, config = hs.config.thirdpartyrules.third_party_event_rules
|
||||||
|
|
||||||
api = hs.get_module_api()
|
api = hs.get_module_api()
|
||||||
third_party_rules = module(config=config, module_api=api)
|
third_party_rules = module(config=config, module_api=api)
|
||||||
|
|
|
@ -277,23 +277,25 @@ class AuthHandler(BaseHandler):
|
||||||
# after the SSO completes and before redirecting them back to their client.
|
# after the SSO completes and before redirecting them back to their client.
|
||||||
# It notifies the user they are about to give access to their matrix account
|
# It notifies the user they are about to give access to their matrix account
|
||||||
# to the client.
|
# to the client.
|
||||||
self._sso_redirect_confirm_template = hs.config.sso_redirect_confirm_template
|
self._sso_redirect_confirm_template = (
|
||||||
|
hs.config.sso.sso_redirect_confirm_template
|
||||||
|
)
|
||||||
|
|
||||||
# The following template is shown during user interactive authentication
|
# The following template is shown during user interactive authentication
|
||||||
# in the fallback auth scenario. It notifies the user that they are
|
# in the fallback auth scenario. It notifies the user that they are
|
||||||
# authenticating for an operation to occur on their account.
|
# authenticating for an operation to occur on their account.
|
||||||
self._sso_auth_confirm_template = hs.config.sso_auth_confirm_template
|
self._sso_auth_confirm_template = hs.config.sso.sso_auth_confirm_template
|
||||||
|
|
||||||
# The following template is shown during the SSO authentication process if
|
# The following template is shown during the SSO authentication process if
|
||||||
# the account is deactivated.
|
# the account is deactivated.
|
||||||
self._sso_account_deactivated_template = (
|
self._sso_account_deactivated_template = (
|
||||||
hs.config.sso_account_deactivated_template
|
hs.config.sso.sso_account_deactivated_template
|
||||||
)
|
)
|
||||||
|
|
||||||
self._server_name = hs.config.server.server_name
|
self._server_name = hs.config.server.server_name
|
||||||
|
|
||||||
# cast to tuple for use with str.startswith
|
# cast to tuple for use with str.startswith
|
||||||
self._whitelisted_sso_clients = tuple(hs.config.sso_client_whitelist)
|
self._whitelisted_sso_clients = tuple(hs.config.sso.sso_client_whitelist)
|
||||||
|
|
||||||
# A mapping of user ID to extra attributes to include in the login
|
# A mapping of user ID to extra attributes to include in the login
|
||||||
# response.
|
# response.
|
||||||
|
|
|
@ -48,7 +48,7 @@ class DirectoryHandler(BaseHandler):
|
||||||
self.event_creation_handler = hs.get_event_creation_handler()
|
self.event_creation_handler = hs.get_event_creation_handler()
|
||||||
self.store = hs.get_datastore()
|
self.store = hs.get_datastore()
|
||||||
self.config = hs.config
|
self.config = hs.config
|
||||||
self.enable_room_list_search = hs.config.enable_room_list_search
|
self.enable_room_list_search = hs.config.roomdirectory.enable_room_list_search
|
||||||
self.require_membership = hs.config.require_membership_for_aliases
|
self.require_membership = hs.config.require_membership_for_aliases
|
||||||
self.third_party_event_rules = hs.get_third_party_event_rules()
|
self.third_party_event_rules = hs.get_third_party_event_rules()
|
||||||
|
|
||||||
|
@ -143,7 +143,7 @@ class DirectoryHandler(BaseHandler):
|
||||||
):
|
):
|
||||||
raise AuthError(403, "This user is not permitted to create this alias")
|
raise AuthError(403, "This user is not permitted to create this alias")
|
||||||
|
|
||||||
if not self.config.is_alias_creation_allowed(
|
if not self.config.roomdirectory.is_alias_creation_allowed(
|
||||||
user_id, room_id, room_alias_str
|
user_id, room_id, room_alias_str
|
||||||
):
|
):
|
||||||
# Lets just return a generic message, as there may be all sorts of
|
# Lets just return a generic message, as there may be all sorts of
|
||||||
|
@ -459,7 +459,7 @@ class DirectoryHandler(BaseHandler):
|
||||||
if canonical_alias:
|
if canonical_alias:
|
||||||
room_aliases.append(canonical_alias)
|
room_aliases.append(canonical_alias)
|
||||||
|
|
||||||
if not self.config.is_publishing_room_allowed(
|
if not self.config.roomdirectory.is_publishing_room_allowed(
|
||||||
user_id, room_id, room_aliases
|
user_id, room_id, room_aliases
|
||||||
):
|
):
|
||||||
# Lets just return a generic message, as there may be all sorts of
|
# Lets just return a generic message, as there may be all sorts of
|
||||||
|
|
|
@ -91,7 +91,7 @@ class FederationHandler(BaseHandler):
|
||||||
self.spam_checker = hs.get_spam_checker()
|
self.spam_checker = hs.get_spam_checker()
|
||||||
self.event_creation_handler = hs.get_event_creation_handler()
|
self.event_creation_handler = hs.get_event_creation_handler()
|
||||||
self._event_auth_handler = hs.get_event_auth_handler()
|
self._event_auth_handler = hs.get_event_auth_handler()
|
||||||
self._server_notices_mxid = hs.config.server_notices_mxid
|
self._server_notices_mxid = hs.config.servernotices.server_notices_mxid
|
||||||
self.config = hs.config
|
self.config = hs.config
|
||||||
self.http_client = hs.get_proxied_blacklisted_http_client()
|
self.http_client = hs.get_proxied_blacklisted_http_client()
|
||||||
self._replication = hs.get_replication_data_handler()
|
self._replication = hs.get_replication_data_handler()
|
||||||
|
|
|
@ -692,10 +692,10 @@ class EventCreationHandler:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
async def _is_server_notices_room(self, room_id: str) -> bool:
|
async def _is_server_notices_room(self, room_id: str) -> bool:
|
||||||
if self.config.server_notices_mxid is None:
|
if self.config.servernotices.server_notices_mxid is None:
|
||||||
return False
|
return False
|
||||||
user_ids = await self.store.get_users_in_room(room_id)
|
user_ids = await self.store.get_users_in_room(room_id)
|
||||||
return self.config.server_notices_mxid in user_ids
|
return self.config.servernotices.server_notices_mxid in user_ids
|
||||||
|
|
||||||
async def assert_accepted_privacy_policy(self, requester: Requester) -> None:
|
async def assert_accepted_privacy_policy(self, requester: Requester) -> None:
|
||||||
"""Check if a user has accepted the privacy policy
|
"""Check if a user has accepted the privacy policy
|
||||||
|
@ -731,8 +731,8 @@ class EventCreationHandler:
|
||||||
|
|
||||||
# exempt the system notices user
|
# exempt the system notices user
|
||||||
if (
|
if (
|
||||||
self.config.server_notices_mxid is not None
|
self.config.servernotices.server_notices_mxid is not None
|
||||||
and user_id == self.config.server_notices_mxid
|
and user_id == self.config.servernotices.server_notices_mxid
|
||||||
):
|
):
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
|
@ -98,7 +98,7 @@ class RegistrationHandler(BaseHandler):
|
||||||
self.macaroon_gen = hs.get_macaroon_generator()
|
self.macaroon_gen = hs.get_macaroon_generator()
|
||||||
self._account_validity_handler = hs.get_account_validity_handler()
|
self._account_validity_handler = hs.get_account_validity_handler()
|
||||||
self._user_consent_version = self.hs.config.consent.user_consent_version
|
self._user_consent_version = self.hs.config.consent.user_consent_version
|
||||||
self._server_notices_mxid = hs.config.server_notices_mxid
|
self._server_notices_mxid = hs.config.servernotices.server_notices_mxid
|
||||||
self._server_name = hs.hostname
|
self._server_name = hs.hostname
|
||||||
|
|
||||||
self.spam_checker = hs.get_spam_checker()
|
self.spam_checker = hs.get_spam_checker()
|
||||||
|
|
|
@ -126,7 +126,7 @@ class RoomCreationHandler(BaseHandler):
|
||||||
for preset_name, preset_config in self._presets_dict.items():
|
for preset_name, preset_config in self._presets_dict.items():
|
||||||
encrypted = (
|
encrypted = (
|
||||||
preset_name
|
preset_name
|
||||||
in self.config.encryption_enabled_by_default_for_room_presets
|
in self.config.room.encryption_enabled_by_default_for_room_presets
|
||||||
)
|
)
|
||||||
preset_config["encrypted"] = encrypted
|
preset_config["encrypted"] = encrypted
|
||||||
|
|
||||||
|
@ -141,7 +141,7 @@ class RoomCreationHandler(BaseHandler):
|
||||||
self._upgrade_response_cache: ResponseCache[Tuple[str, str]] = ResponseCache(
|
self._upgrade_response_cache: ResponseCache[Tuple[str, str]] = ResponseCache(
|
||||||
hs.get_clock(), "room_upgrade", timeout_ms=FIVE_MINUTES_IN_MS
|
hs.get_clock(), "room_upgrade", timeout_ms=FIVE_MINUTES_IN_MS
|
||||||
)
|
)
|
||||||
self._server_notices_mxid = hs.config.server_notices_mxid
|
self._server_notices_mxid = hs.config.servernotices.server_notices_mxid
|
||||||
|
|
||||||
self.third_party_event_rules = hs.get_third_party_event_rules()
|
self.third_party_event_rules = hs.get_third_party_event_rules()
|
||||||
|
|
||||||
|
@ -757,7 +757,9 @@ class RoomCreationHandler(BaseHandler):
|
||||||
)
|
)
|
||||||
|
|
||||||
if is_public:
|
if is_public:
|
||||||
if not self.config.is_publishing_room_allowed(user_id, room_id, room_alias):
|
if not self.config.roomdirectory.is_publishing_room_allowed(
|
||||||
|
user_id, room_id, room_alias
|
||||||
|
):
|
||||||
# Lets just return a generic message, as there may be all sorts of
|
# Lets just return a generic message, as there may be all sorts of
|
||||||
# reasons why we said no. TODO: Allow configurable error messages
|
# reasons why we said no. TODO: Allow configurable error messages
|
||||||
# per alias creation rule?
|
# per alias creation rule?
|
||||||
|
|
|
@ -52,7 +52,7 @@ EMPTY_THIRD_PARTY_ID = ThirdPartyInstanceID(None, None)
|
||||||
class RoomListHandler(BaseHandler):
|
class RoomListHandler(BaseHandler):
|
||||||
def __init__(self, hs: "HomeServer"):
|
def __init__(self, hs: "HomeServer"):
|
||||||
super().__init__(hs)
|
super().__init__(hs)
|
||||||
self.enable_room_list_search = hs.config.enable_room_list_search
|
self.enable_room_list_search = hs.config.roomdirectory.enable_room_list_search
|
||||||
self.response_cache: ResponseCache[
|
self.response_cache: ResponseCache[
|
||||||
Tuple[Optional[int], Optional[str], Optional[ThirdPartyInstanceID]]
|
Tuple[Optional[int], Optional[str], Optional[ThirdPartyInstanceID]]
|
||||||
] = ResponseCache(hs.get_clock(), "room_list")
|
] = ResponseCache(hs.get_clock(), "room_list")
|
||||||
|
|
|
@ -88,7 +88,7 @@ class RoomMemberHandler(metaclass=abc.ABCMeta):
|
||||||
self.clock = hs.get_clock()
|
self.clock = hs.get_clock()
|
||||||
self.spam_checker = hs.get_spam_checker()
|
self.spam_checker = hs.get_spam_checker()
|
||||||
self.third_party_event_rules = hs.get_third_party_event_rules()
|
self.third_party_event_rules = hs.get_third_party_event_rules()
|
||||||
self._server_notices_mxid = self.config.server_notices_mxid
|
self._server_notices_mxid = self.config.servernotices.server_notices_mxid
|
||||||
self._enable_lookup = hs.config.enable_3pid_lookup
|
self._enable_lookup = hs.config.enable_3pid_lookup
|
||||||
self.allow_per_room_profiles = self.config.allow_per_room_profiles
|
self.allow_per_room_profiles = self.config.allow_per_room_profiles
|
||||||
|
|
||||||
|
|
|
@ -54,19 +54,18 @@ class Saml2SessionData:
|
||||||
class SamlHandler(BaseHandler):
|
class SamlHandler(BaseHandler):
|
||||||
def __init__(self, hs: "HomeServer"):
|
def __init__(self, hs: "HomeServer"):
|
||||||
super().__init__(hs)
|
super().__init__(hs)
|
||||||
self._saml_client = Saml2Client(hs.config.saml2_sp_config)
|
self._saml_client = Saml2Client(hs.config.saml2.saml2_sp_config)
|
||||||
self._saml_idp_entityid = hs.config.saml2_idp_entityid
|
self._saml_idp_entityid = hs.config.saml2.saml2_idp_entityid
|
||||||
|
|
||||||
self._saml2_session_lifetime = hs.config.saml2_session_lifetime
|
self._saml2_session_lifetime = hs.config.saml2.saml2_session_lifetime
|
||||||
self._grandfathered_mxid_source_attribute = (
|
self._grandfathered_mxid_source_attribute = (
|
||||||
hs.config.saml2_grandfathered_mxid_source_attribute
|
hs.config.saml2.saml2_grandfathered_mxid_source_attribute
|
||||||
)
|
)
|
||||||
self._saml2_attribute_requirements = hs.config.saml2.attribute_requirements
|
self._saml2_attribute_requirements = hs.config.saml2.attribute_requirements
|
||||||
self._error_template = hs.config.sso_error_template
|
|
||||||
|
|
||||||
# plugin to do custom mapping from saml response to mxid
|
# plugin to do custom mapping from saml response to mxid
|
||||||
self._user_mapping_provider = hs.config.saml2_user_mapping_provider_class(
|
self._user_mapping_provider = hs.config.saml2.saml2_user_mapping_provider_class(
|
||||||
hs.config.saml2_user_mapping_provider_config,
|
hs.config.saml2.saml2_user_mapping_provider_config,
|
||||||
ModuleApi(hs, hs.get_auth_handler()),
|
ModuleApi(hs, hs.get_auth_handler()),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -411,7 +410,7 @@ class DefaultSamlMappingProvider:
|
||||||
self._mxid_mapper = parsed_config.mxid_mapper
|
self._mxid_mapper = parsed_config.mxid_mapper
|
||||||
|
|
||||||
self._grandfathered_mxid_source_attribute = (
|
self._grandfathered_mxid_source_attribute = (
|
||||||
module_api._hs.config.saml2_grandfathered_mxid_source_attribute
|
module_api._hs.config.saml2.saml2_grandfathered_mxid_source_attribute
|
||||||
)
|
)
|
||||||
|
|
||||||
def get_remote_user_id(
|
def get_remote_user_id(
|
||||||
|
|
|
@ -184,15 +184,17 @@ class SsoHandler:
|
||||||
self._server_name = hs.hostname
|
self._server_name = hs.hostname
|
||||||
self._registration_handler = hs.get_registration_handler()
|
self._registration_handler = hs.get_registration_handler()
|
||||||
self._auth_handler = hs.get_auth_handler()
|
self._auth_handler = hs.get_auth_handler()
|
||||||
self._error_template = hs.config.sso_error_template
|
self._error_template = hs.config.sso.sso_error_template
|
||||||
self._bad_user_template = hs.config.sso_auth_bad_user_template
|
self._bad_user_template = hs.config.sso.sso_auth_bad_user_template
|
||||||
self._profile_handler = hs.get_profile_handler()
|
self._profile_handler = hs.get_profile_handler()
|
||||||
|
|
||||||
# The following template is shown after a successful user interactive
|
# The following template is shown after a successful user interactive
|
||||||
# authentication session. It tells the user they can close the window.
|
# authentication session. It tells the user they can close the window.
|
||||||
self._sso_auth_success_template = hs.config.sso_auth_success_template
|
self._sso_auth_success_template = hs.config.sso.sso_auth_success_template
|
||||||
|
|
||||||
self._sso_update_profile_information = hs.config.sso_update_profile_information
|
self._sso_update_profile_information = (
|
||||||
|
hs.config.sso.sso_update_profile_information
|
||||||
|
)
|
||||||
|
|
||||||
# a lock on the mappings
|
# a lock on the mappings
|
||||||
self._mapping_lock = Linearizer(name="sso_user_mapping", clock=hs.get_clock())
|
self._mapping_lock = Linearizer(name="sso_user_mapping", clock=hs.get_clock())
|
||||||
|
|
|
@ -46,7 +46,7 @@ class StatsHandler:
|
||||||
self.notifier = hs.get_notifier()
|
self.notifier = hs.get_notifier()
|
||||||
self.is_mine_id = hs.is_mine_id
|
self.is_mine_id = hs.is_mine_id
|
||||||
|
|
||||||
self.stats_enabled = hs.config.stats_enabled
|
self.stats_enabled = hs.config.stats.stats_enabled
|
||||||
|
|
||||||
# The current position in the current_state_delta stream
|
# The current position in the current_state_delta stream
|
||||||
self.pos: Optional[int] = None
|
self.pos: Optional[int] = None
|
||||||
|
|
|
@ -61,7 +61,7 @@ class UserDirectoryHandler(StateDeltasHandler):
|
||||||
self.notifier = hs.get_notifier()
|
self.notifier = hs.get_notifier()
|
||||||
self.is_mine_id = hs.is_mine_id
|
self.is_mine_id = hs.is_mine_id
|
||||||
self.update_user_directory = hs.config.update_user_directory
|
self.update_user_directory = hs.config.update_user_directory
|
||||||
self.search_all_users = hs.config.user_directory_search_all_users
|
self.search_all_users = hs.config.userdirectory.user_directory_search_all_users
|
||||||
self.spam_checker = hs.get_spam_checker()
|
self.spam_checker = hs.get_spam_checker()
|
||||||
# The current position in the current_state_delta stream
|
# The current position in the current_state_delta stream
|
||||||
self.pos: Optional[int] = None
|
self.pos: Optional[int] = None
|
||||||
|
|
|
@ -363,7 +363,7 @@ def noop_context_manager(*args, **kwargs):
|
||||||
def init_tracer(hs: "HomeServer"):
|
def init_tracer(hs: "HomeServer"):
|
||||||
"""Set the whitelists and initialise the JaegerClient tracer"""
|
"""Set the whitelists and initialise the JaegerClient tracer"""
|
||||||
global opentracing
|
global opentracing
|
||||||
if not hs.config.opentracer_enabled:
|
if not hs.config.tracing.opentracer_enabled:
|
||||||
# We don't have a tracer
|
# We don't have a tracer
|
||||||
opentracing = None
|
opentracing = None
|
||||||
return
|
return
|
||||||
|
@ -377,12 +377,12 @@ def init_tracer(hs: "HomeServer"):
|
||||||
# Pull out the jaeger config if it was given. Otherwise set it to something sensible.
|
# Pull out the jaeger config if it was given. Otherwise set it to something sensible.
|
||||||
# See https://github.com/jaegertracing/jaeger-client-python/blob/master/jaeger_client/config.py
|
# See https://github.com/jaegertracing/jaeger-client-python/blob/master/jaeger_client/config.py
|
||||||
|
|
||||||
set_homeserver_whitelist(hs.config.opentracer_whitelist)
|
set_homeserver_whitelist(hs.config.tracing.opentracer_whitelist)
|
||||||
|
|
||||||
from jaeger_client.metrics.prometheus import PrometheusMetricsFactory
|
from jaeger_client.metrics.prometheus import PrometheusMetricsFactory
|
||||||
|
|
||||||
config = JaegerConfig(
|
config = JaegerConfig(
|
||||||
config=hs.config.jaeger_config,
|
config=hs.config.tracing.jaeger_config,
|
||||||
service_name=f"{hs.config.server.server_name} {hs.get_instance_name()}",
|
service_name=f"{hs.config.server.server_name} {hs.get_instance_name()}",
|
||||||
scope_manager=LogContextScopeManager(hs.config),
|
scope_manager=LogContextScopeManager(hs.config),
|
||||||
metrics_factory=PrometheusMetricsFactory(),
|
metrics_factory=PrometheusMetricsFactory(),
|
||||||
|
|
|
@ -168,8 +168,8 @@ class ReplicationEndpoint(metaclass=abc.ABCMeta):
|
||||||
client = hs.get_simple_http_client()
|
client = hs.get_simple_http_client()
|
||||||
local_instance_name = hs.get_instance_name()
|
local_instance_name = hs.get_instance_name()
|
||||||
|
|
||||||
master_host = hs.config.worker_replication_host
|
master_host = hs.config.worker.worker_replication_host
|
||||||
master_port = hs.config.worker_replication_http_port
|
master_port = hs.config.worker.worker_replication_http_port
|
||||||
|
|
||||||
instance_map = hs.config.worker.instance_map
|
instance_map = hs.config.worker.instance_map
|
||||||
|
|
||||||
|
|
|
@ -322,8 +322,8 @@ class ReplicationCommandHandler:
|
||||||
else:
|
else:
|
||||||
client_name = hs.get_instance_name()
|
client_name = hs.get_instance_name()
|
||||||
self._factory = DirectTcpReplicationClientFactory(hs, client_name, self)
|
self._factory = DirectTcpReplicationClientFactory(hs, client_name, self)
|
||||||
host = hs.config.worker_replication_host
|
host = hs.config.worker.worker_replication_host
|
||||||
port = hs.config.worker_replication_port
|
port = hs.config.worker.worker_replication_port
|
||||||
hs.get_reactor().connectTCP(host.encode(), port, self._factory)
|
hs.get_reactor().connectTCP(host.encode(), port, self._factory)
|
||||||
|
|
||||||
def get_streams(self) -> Dict[str, Stream]:
|
def get_streams(self) -> Dict[str, Stream]:
|
||||||
|
|
|
@ -267,7 +267,7 @@ def register_servlets_for_client_rest_resource(
|
||||||
|
|
||||||
# Load the media repo ones if we're using them. Otherwise load the servlets which
|
# Load the media repo ones if we're using them. Otherwise load the servlets which
|
||||||
# don't need a media repo (typically readonly admin APIs).
|
# don't need a media repo (typically readonly admin APIs).
|
||||||
if hs.config.can_load_media_repo:
|
if hs.config.media.can_load_media_repo:
|
||||||
register_servlets_for_media_repo(hs, http_server)
|
register_servlets_for_media_repo(hs, http_server)
|
||||||
else:
|
else:
|
||||||
ListMediaInRoom(hs).register(http_server)
|
ListMediaInRoom(hs).register(http_server)
|
||||||
|
|
|
@ -76,7 +76,7 @@ class LoginRestServlet(RestServlet):
|
||||||
self.jwt_audiences = hs.config.jwt.jwt_audiences
|
self.jwt_audiences = hs.config.jwt.jwt_audiences
|
||||||
|
|
||||||
# SSO configuration.
|
# SSO configuration.
|
||||||
self.saml2_enabled = hs.config.saml2_enabled
|
self.saml2_enabled = hs.config.saml2.saml2_enabled
|
||||||
self.cas_enabled = hs.config.cas.cas_enabled
|
self.cas_enabled = hs.config.cas.cas_enabled
|
||||||
self.oidc_enabled = hs.config.oidc.oidc_enabled
|
self.oidc_enabled = hs.config.oidc.oidc_enabled
|
||||||
self._msc2918_enabled = hs.config.access_token_lifetime is not None
|
self._msc2918_enabled = hs.config.access_token_lifetime is not None
|
||||||
|
|
|
@ -58,7 +58,7 @@ class UserDirectorySearchRestServlet(RestServlet):
|
||||||
requester = await self.auth.get_user_by_req(request, allow_guest=False)
|
requester = await self.auth.get_user_by_req(request, allow_guest=False)
|
||||||
user_id = requester.user.to_string()
|
user_id = requester.user.to_string()
|
||||||
|
|
||||||
if not self.hs.config.user_directory_search_enabled:
|
if not self.hs.config.userdirectory.user_directory_search_enabled:
|
||||||
return 200, {"limited": False, "results": []}
|
return 200, {"limited": False, "results": []}
|
||||||
|
|
||||||
body = parse_json_object_from_request(request)
|
body = parse_json_object_from_request(request)
|
||||||
|
|
|
@ -42,15 +42,15 @@ class VersionsRestServlet(RestServlet):
|
||||||
# Calculate these once since they shouldn't change after start-up.
|
# Calculate these once since they shouldn't change after start-up.
|
||||||
self.e2ee_forced_public = (
|
self.e2ee_forced_public = (
|
||||||
RoomCreationPreset.PUBLIC_CHAT
|
RoomCreationPreset.PUBLIC_CHAT
|
||||||
in self.config.encryption_enabled_by_default_for_room_presets
|
in self.config.room.encryption_enabled_by_default_for_room_presets
|
||||||
)
|
)
|
||||||
self.e2ee_forced_private = (
|
self.e2ee_forced_private = (
|
||||||
RoomCreationPreset.PRIVATE_CHAT
|
RoomCreationPreset.PRIVATE_CHAT
|
||||||
in self.config.encryption_enabled_by_default_for_room_presets
|
in self.config.room.encryption_enabled_by_default_for_room_presets
|
||||||
)
|
)
|
||||||
self.e2ee_forced_trusted_private = (
|
self.e2ee_forced_trusted_private = (
|
||||||
RoomCreationPreset.TRUSTED_PRIVATE_CHAT
|
RoomCreationPreset.TRUSTED_PRIVATE_CHAT
|
||||||
in self.config.encryption_enabled_by_default_for_room_presets
|
in self.config.room.encryption_enabled_by_default_for_room_presets
|
||||||
)
|
)
|
||||||
|
|
||||||
def on_GET(self, request: Request) -> Tuple[int, JsonDict]:
|
def on_GET(self, request: Request) -> Tuple[int, JsonDict]:
|
||||||
|
|
|
@ -37,14 +37,14 @@ class VoipRestServlet(RestServlet):
|
||||||
|
|
||||||
async def on_GET(self, request: SynapseRequest) -> Tuple[int, JsonDict]:
|
async def on_GET(self, request: SynapseRequest) -> Tuple[int, JsonDict]:
|
||||||
requester = await self.auth.get_user_by_req(
|
requester = await self.auth.get_user_by_req(
|
||||||
request, self.hs.config.turn_allow_guests
|
request, self.hs.config.voip.turn_allow_guests
|
||||||
)
|
)
|
||||||
|
|
||||||
turnUris = self.hs.config.turn_uris
|
turnUris = self.hs.config.voip.turn_uris
|
||||||
turnSecret = self.hs.config.turn_shared_secret
|
turnSecret = self.hs.config.voip.turn_shared_secret
|
||||||
turnUsername = self.hs.config.turn_username
|
turnUsername = self.hs.config.voip.turn_username
|
||||||
turnPassword = self.hs.config.turn_password
|
turnPassword = self.hs.config.voip.turn_password
|
||||||
userLifetime = self.hs.config.turn_user_lifetime
|
userLifetime = self.hs.config.voip.turn_user_lifetime
|
||||||
|
|
||||||
if turnUris and turnSecret and userLifetime:
|
if turnUris and turnSecret and userLifetime:
|
||||||
expiry = (self.hs.get_clock().time_msec() + userLifetime) / 1000
|
expiry = (self.hs.get_clock().time_msec() + userLifetime) / 1000
|
||||||
|
|
|
@ -31,7 +31,7 @@ class MediaConfigResource(DirectServeJsonResource):
|
||||||
config = hs.config
|
config = hs.config
|
||||||
self.clock = hs.get_clock()
|
self.clock = hs.get_clock()
|
||||||
self.auth = hs.get_auth()
|
self.auth = hs.get_auth()
|
||||||
self.limits_dict = {"m.upload.size": config.max_upload_size}
|
self.limits_dict = {"m.upload.size": config.media.max_upload_size}
|
||||||
|
|
||||||
async def _async_render_GET(self, request: SynapseRequest) -> None:
|
async def _async_render_GET(self, request: SynapseRequest) -> None:
|
||||||
await self.auth.get_user_by_req(request)
|
await self.auth.get_user_by_req(request)
|
||||||
|
|
|
@ -76,16 +76,16 @@ class MediaRepository:
|
||||||
self.clock = hs.get_clock()
|
self.clock = hs.get_clock()
|
||||||
self.server_name = hs.hostname
|
self.server_name = hs.hostname
|
||||||
self.store = hs.get_datastore()
|
self.store = hs.get_datastore()
|
||||||
self.max_upload_size = hs.config.max_upload_size
|
self.max_upload_size = hs.config.media.max_upload_size
|
||||||
self.max_image_pixels = hs.config.max_image_pixels
|
self.max_image_pixels = hs.config.media.max_image_pixels
|
||||||
|
|
||||||
Thumbnailer.set_limits(self.max_image_pixels)
|
Thumbnailer.set_limits(self.max_image_pixels)
|
||||||
|
|
||||||
self.primary_base_path: str = hs.config.media_store_path
|
self.primary_base_path: str = hs.config.media.media_store_path
|
||||||
self.filepaths: MediaFilePaths = MediaFilePaths(self.primary_base_path)
|
self.filepaths: MediaFilePaths = MediaFilePaths(self.primary_base_path)
|
||||||
|
|
||||||
self.dynamic_thumbnails = hs.config.dynamic_thumbnails
|
self.dynamic_thumbnails = hs.config.media.dynamic_thumbnails
|
||||||
self.thumbnail_requirements = hs.config.thumbnail_requirements
|
self.thumbnail_requirements = hs.config.media.thumbnail_requirements
|
||||||
|
|
||||||
self.remote_media_linearizer = Linearizer(name="media_remote")
|
self.remote_media_linearizer = Linearizer(name="media_remote")
|
||||||
|
|
||||||
|
@ -100,7 +100,11 @@ class MediaRepository:
|
||||||
# potentially upload to.
|
# potentially upload to.
|
||||||
storage_providers = []
|
storage_providers = []
|
||||||
|
|
||||||
for clz, provider_config, wrapper_config in hs.config.media_storage_providers:
|
for (
|
||||||
|
clz,
|
||||||
|
provider_config,
|
||||||
|
wrapper_config,
|
||||||
|
) in hs.config.media.media_storage_providers:
|
||||||
backend = clz(hs, provider_config)
|
backend = clz(hs, provider_config)
|
||||||
provider = StorageProviderWrapper(
|
provider = StorageProviderWrapper(
|
||||||
backend,
|
backend,
|
||||||
|
@ -975,7 +979,7 @@ class MediaRepositoryResource(Resource):
|
||||||
|
|
||||||
def __init__(self, hs: "HomeServer"):
|
def __init__(self, hs: "HomeServer"):
|
||||||
# If we're not configured to use it, raise if we somehow got here.
|
# If we're not configured to use it, raise if we somehow got here.
|
||||||
if not hs.config.can_load_media_repo:
|
if not hs.config.media.can_load_media_repo:
|
||||||
raise ConfigError("Synapse is not configured to use a media repo.")
|
raise ConfigError("Synapse is not configured to use a media repo.")
|
||||||
|
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
@ -986,7 +990,7 @@ class MediaRepositoryResource(Resource):
|
||||||
self.putChild(
|
self.putChild(
|
||||||
b"thumbnail", ThumbnailResource(hs, media_repo, media_repo.media_storage)
|
b"thumbnail", ThumbnailResource(hs, media_repo, media_repo.media_storage)
|
||||||
)
|
)
|
||||||
if hs.config.url_preview_enabled:
|
if hs.config.media.url_preview_enabled:
|
||||||
self.putChild(
|
self.putChild(
|
||||||
b"preview_url",
|
b"preview_url",
|
||||||
PreviewUrlResource(hs, media_repo, media_repo.media_storage),
|
PreviewUrlResource(hs, media_repo, media_repo.media_storage),
|
||||||
|
|
|
@ -125,14 +125,14 @@ class PreviewUrlResource(DirectServeJsonResource):
|
||||||
self.auth = hs.get_auth()
|
self.auth = hs.get_auth()
|
||||||
self.clock = hs.get_clock()
|
self.clock = hs.get_clock()
|
||||||
self.filepaths = media_repo.filepaths
|
self.filepaths = media_repo.filepaths
|
||||||
self.max_spider_size = hs.config.max_spider_size
|
self.max_spider_size = hs.config.media.max_spider_size
|
||||||
self.server_name = hs.hostname
|
self.server_name = hs.hostname
|
||||||
self.store = hs.get_datastore()
|
self.store = hs.get_datastore()
|
||||||
self.client = SimpleHttpClient(
|
self.client = SimpleHttpClient(
|
||||||
hs,
|
hs,
|
||||||
treq_args={"browser_like_redirects": True},
|
treq_args={"browser_like_redirects": True},
|
||||||
ip_whitelist=hs.config.url_preview_ip_range_whitelist,
|
ip_whitelist=hs.config.media.url_preview_ip_range_whitelist,
|
||||||
ip_blacklist=hs.config.url_preview_ip_range_blacklist,
|
ip_blacklist=hs.config.media.url_preview_ip_range_blacklist,
|
||||||
use_proxy=True,
|
use_proxy=True,
|
||||||
)
|
)
|
||||||
self.media_repo = media_repo
|
self.media_repo = media_repo
|
||||||
|
@ -150,8 +150,8 @@ class PreviewUrlResource(DirectServeJsonResource):
|
||||||
or instance_running_jobs == hs.get_instance_name()
|
or instance_running_jobs == hs.get_instance_name()
|
||||||
)
|
)
|
||||||
|
|
||||||
self.url_preview_url_blacklist = hs.config.url_preview_url_blacklist
|
self.url_preview_url_blacklist = hs.config.media.url_preview_url_blacklist
|
||||||
self.url_preview_accept_language = hs.config.url_preview_accept_language
|
self.url_preview_accept_language = hs.config.media.url_preview_accept_language
|
||||||
|
|
||||||
# memory cache mapping urls to an ObservableDeferred returning
|
# memory cache mapping urls to an ObservableDeferred returning
|
||||||
# JSON-encoded OG metadata
|
# JSON-encoded OG metadata
|
||||||
|
|
|
@ -125,7 +125,7 @@ class FileStorageProviderBackend(StorageProvider):
|
||||||
|
|
||||||
def __init__(self, hs: "HomeServer", config: str):
|
def __init__(self, hs: "HomeServer", config: str):
|
||||||
self.hs = hs
|
self.hs = hs
|
||||||
self.cache_directory = hs.config.media_store_path
|
self.cache_directory = hs.config.media.media_store_path
|
||||||
self.base_directory = config
|
self.base_directory = config
|
||||||
|
|
||||||
def __str__(self) -> str:
|
def __str__(self) -> str:
|
||||||
|
|
|
@ -53,7 +53,7 @@ class ThumbnailResource(DirectServeJsonResource):
|
||||||
self.store = hs.get_datastore()
|
self.store = hs.get_datastore()
|
||||||
self.media_repo = media_repo
|
self.media_repo = media_repo
|
||||||
self.media_storage = media_storage
|
self.media_storage = media_storage
|
||||||
self.dynamic_thumbnails = hs.config.dynamic_thumbnails
|
self.dynamic_thumbnails = hs.config.media.dynamic_thumbnails
|
||||||
self.server_name = hs.hostname
|
self.server_name = hs.hostname
|
||||||
|
|
||||||
async def _async_render_GET(self, request: SynapseRequest) -> None:
|
async def _async_render_GET(self, request: SynapseRequest) -> None:
|
||||||
|
|
|
@ -41,7 +41,7 @@ class UploadResource(DirectServeJsonResource):
|
||||||
self.clock = hs.get_clock()
|
self.clock = hs.get_clock()
|
||||||
self.server_name = hs.hostname
|
self.server_name = hs.hostname
|
||||||
self.auth = hs.get_auth()
|
self.auth = hs.get_auth()
|
||||||
self.max_upload_size = hs.config.max_upload_size
|
self.max_upload_size = hs.config.media.max_upload_size
|
||||||
self.clock = hs.get_clock()
|
self.clock = hs.get_clock()
|
||||||
|
|
||||||
async def _async_render_OPTIONS(self, request: SynapseRequest) -> None:
|
async def _async_render_OPTIONS(self, request: SynapseRequest) -> None:
|
||||||
|
|
|
@ -50,7 +50,7 @@ def build_synapse_client_resource_tree(hs: "HomeServer") -> Mapping[str, Resourc
|
||||||
|
|
||||||
resources["/_synapse/client/oidc"] = OIDCResource(hs)
|
resources["/_synapse/client/oidc"] = OIDCResource(hs)
|
||||||
|
|
||||||
if hs.config.saml2_enabled:
|
if hs.config.saml2.saml2_enabled:
|
||||||
from synapse.rest.synapse.client.saml2 import SAML2Resource
|
from synapse.rest.synapse.client.saml2 import SAML2Resource
|
||||||
|
|
||||||
res = SAML2Resource(hs)
|
res = SAML2Resource(hs)
|
||||||
|
|
|
@ -30,7 +30,7 @@ class SAML2MetadataResource(Resource):
|
||||||
|
|
||||||
def __init__(self, hs: "HomeServer"):
|
def __init__(self, hs: "HomeServer"):
|
||||||
Resource.__init__(self)
|
Resource.__init__(self)
|
||||||
self.sp_config = hs.config.saml2_sp_config
|
self.sp_config = hs.config.saml2.saml2_sp_config
|
||||||
|
|
||||||
def render_GET(self, request: Request) -> bytes:
|
def render_GET(self, request: Request) -> bytes:
|
||||||
metadata_xml = saml2.metadata.create_metadata_string(
|
metadata_xml = saml2.metadata.create_metadata_string(
|
||||||
|
|
|
@ -39,7 +39,7 @@ class ServerNoticesManager:
|
||||||
self._server_name = hs.hostname
|
self._server_name = hs.hostname
|
||||||
|
|
||||||
self._notifier = hs.get_notifier()
|
self._notifier = hs.get_notifier()
|
||||||
self.server_notices_mxid = self._config.server_notices_mxid
|
self.server_notices_mxid = self._config.servernotices.server_notices_mxid
|
||||||
|
|
||||||
def is_enabled(self):
|
def is_enabled(self):
|
||||||
"""Checks if server notices are enabled on this server.
|
"""Checks if server notices are enabled on this server.
|
||||||
|
@ -47,7 +47,7 @@ class ServerNoticesManager:
|
||||||
Returns:
|
Returns:
|
||||||
bool
|
bool
|
||||||
"""
|
"""
|
||||||
return self._config.server_notices_mxid is not None
|
return self.server_notices_mxid is not None
|
||||||
|
|
||||||
async def send_notice(
|
async def send_notice(
|
||||||
self,
|
self,
|
||||||
|
@ -71,9 +71,9 @@ class ServerNoticesManager:
|
||||||
room_id = await self.get_or_create_notice_room_for_user(user_id)
|
room_id = await self.get_or_create_notice_room_for_user(user_id)
|
||||||
await self.maybe_invite_user_to_room(user_id, room_id)
|
await self.maybe_invite_user_to_room(user_id, room_id)
|
||||||
|
|
||||||
system_mxid = self._config.server_notices_mxid
|
assert self.server_notices_mxid is not None
|
||||||
requester = create_requester(
|
requester = create_requester(
|
||||||
system_mxid, authenticated_entity=self._server_name
|
self.server_notices_mxid, authenticated_entity=self._server_name
|
||||||
)
|
)
|
||||||
|
|
||||||
logger.info("Sending server notice to %s", user_id)
|
logger.info("Sending server notice to %s", user_id)
|
||||||
|
@ -81,7 +81,7 @@ class ServerNoticesManager:
|
||||||
event_dict = {
|
event_dict = {
|
||||||
"type": type,
|
"type": type,
|
||||||
"room_id": room_id,
|
"room_id": room_id,
|
||||||
"sender": system_mxid,
|
"sender": self.server_notices_mxid,
|
||||||
"content": event_content,
|
"content": event_content,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,7 +106,7 @@ class ServerNoticesManager:
|
||||||
Returns:
|
Returns:
|
||||||
room id of notice room.
|
room id of notice room.
|
||||||
"""
|
"""
|
||||||
if not self.is_enabled():
|
if self.server_notices_mxid is None:
|
||||||
raise Exception("Server notices not enabled")
|
raise Exception("Server notices not enabled")
|
||||||
|
|
||||||
assert self._is_mine_id(user_id), "Cannot send server notices to remote users"
|
assert self._is_mine_id(user_id), "Cannot send server notices to remote users"
|
||||||
|
@ -139,12 +139,12 @@ class ServerNoticesManager:
|
||||||
# avatar, we have to use both.
|
# avatar, we have to use both.
|
||||||
join_profile = None
|
join_profile = None
|
||||||
if (
|
if (
|
||||||
self._config.server_notices_mxid_display_name is not None
|
self._config.servernotices.server_notices_mxid_display_name is not None
|
||||||
or self._config.server_notices_mxid_avatar_url is not None
|
or self._config.servernotices.server_notices_mxid_avatar_url is not None
|
||||||
):
|
):
|
||||||
join_profile = {
|
join_profile = {
|
||||||
"displayname": self._config.server_notices_mxid_display_name,
|
"displayname": self._config.servernotices.server_notices_mxid_display_name,
|
||||||
"avatar_url": self._config.server_notices_mxid_avatar_url,
|
"avatar_url": self._config.servernotices.server_notices_mxid_avatar_url,
|
||||||
}
|
}
|
||||||
|
|
||||||
requester = create_requester(
|
requester = create_requester(
|
||||||
|
@ -154,7 +154,7 @@ class ServerNoticesManager:
|
||||||
requester,
|
requester,
|
||||||
config={
|
config={
|
||||||
"preset": RoomCreationPreset.PRIVATE_CHAT,
|
"preset": RoomCreationPreset.PRIVATE_CHAT,
|
||||||
"name": self._config.server_notices_room_name,
|
"name": self._config.servernotices.server_notices_room_name,
|
||||||
"power_level_content_override": {"users_default": -10},
|
"power_level_content_override": {"users_default": -10},
|
||||||
},
|
},
|
||||||
ratelimit=False,
|
ratelimit=False,
|
||||||
|
@ -178,6 +178,7 @@ class ServerNoticesManager:
|
||||||
user_id: The ID of the user to invite.
|
user_id: The ID of the user to invite.
|
||||||
room_id: The ID of the room to invite the user to.
|
room_id: The ID of the room to invite the user to.
|
||||||
"""
|
"""
|
||||||
|
assert self.server_notices_mxid is not None
|
||||||
requester = create_requester(
|
requester = create_requester(
|
||||||
self.server_notices_mxid, authenticated_entity=self._server_name
|
self.server_notices_mxid, authenticated_entity=self._server_name
|
||||||
)
|
)
|
||||||
|
|
|
@ -2015,7 +2015,7 @@ class RegistrationStore(StatsStore, RegistrationBackgroundUpdateStore):
|
||||||
(user_id_obj.localpart, create_profile_with_displayname),
|
(user_id_obj.localpart, create_profile_with_displayname),
|
||||||
)
|
)
|
||||||
|
|
||||||
if self.hs.config.stats_enabled:
|
if self.hs.config.stats.stats_enabled:
|
||||||
# we create a new completed user statistics row
|
# we create a new completed user statistics row
|
||||||
|
|
||||||
# we don't strictly need current_token since this user really can't
|
# we don't strictly need current_token since this user really can't
|
||||||
|
|
|
@ -98,7 +98,7 @@ class StatsStore(StateDeltasStore):
|
||||||
|
|
||||||
self.server_name = hs.hostname
|
self.server_name = hs.hostname
|
||||||
self.clock = self.hs.get_clock()
|
self.clock = self.hs.get_clock()
|
||||||
self.stats_enabled = hs.config.stats_enabled
|
self.stats_enabled = hs.config.stats.stats_enabled
|
||||||
|
|
||||||
self.stats_delta_processing_lock = DeferredLock()
|
self.stats_delta_processing_lock = DeferredLock()
|
||||||
|
|
||||||
|
|
|
@ -551,7 +551,7 @@ class UserDirectoryStore(UserDirectoryBackgroundUpdateStore):
|
||||||
super().__init__(database, db_conn, hs)
|
super().__init__(database, db_conn, hs)
|
||||||
|
|
||||||
self._prefer_local_users_in_search = (
|
self._prefer_local_users_in_search = (
|
||||||
hs.config.user_directory_search_prefer_local_users
|
hs.config.userdirectory.user_directory_search_prefer_local_users
|
||||||
)
|
)
|
||||||
self._server_name = hs.config.server.server_name
|
self._server_name = hs.config.server.server_name
|
||||||
|
|
||||||
|
@ -741,7 +741,7 @@ class UserDirectoryStore(UserDirectoryBackgroundUpdateStore):
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if self.hs.config.user_directory_search_all_users:
|
if self.hs.config.userdirectory.user_directory_search_all_users:
|
||||||
join_args = (user_id,)
|
join_args = (user_id,)
|
||||||
where_clause = "user_id != ?"
|
where_clause = "user_id != ?"
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -405,7 +405,9 @@ class TestCreateAliasACL(unittest.HomeserverTestCase):
|
||||||
rd_config = RoomDirectoryConfig()
|
rd_config = RoomDirectoryConfig()
|
||||||
rd_config.read_config(config)
|
rd_config.read_config(config)
|
||||||
|
|
||||||
self.hs.config.is_alias_creation_allowed = rd_config.is_alias_creation_allowed
|
self.hs.config.roomdirectory.is_alias_creation_allowed = (
|
||||||
|
rd_config.is_alias_creation_allowed
|
||||||
|
)
|
||||||
|
|
||||||
return hs
|
return hs
|
||||||
|
|
||||||
|
|
|
@ -118,7 +118,7 @@ class StatsRoomTests(unittest.HomeserverTestCase):
|
||||||
self.assertEqual(len(r), 0)
|
self.assertEqual(len(r), 0)
|
||||||
|
|
||||||
# Disable stats
|
# Disable stats
|
||||||
self.hs.config.stats_enabled = False
|
self.hs.config.stats.stats_enabled = False
|
||||||
self.handler.stats_enabled = False
|
self.handler.stats_enabled = False
|
||||||
|
|
||||||
u1 = self.register_user("u1", "pass")
|
u1 = self.register_user("u1", "pass")
|
||||||
|
@ -134,7 +134,7 @@ class StatsRoomTests(unittest.HomeserverTestCase):
|
||||||
self.assertEqual(len(r), 0)
|
self.assertEqual(len(r), 0)
|
||||||
|
|
||||||
# Enable stats
|
# Enable stats
|
||||||
self.hs.config.stats_enabled = True
|
self.hs.config.stats.stats_enabled = True
|
||||||
self.handler.stats_enabled = True
|
self.handler.stats_enabled = True
|
||||||
|
|
||||||
# Do the initial population of the user directory via the background update
|
# Do the initial population of the user directory via the background update
|
||||||
|
@ -469,7 +469,7 @@ class StatsRoomTests(unittest.HomeserverTestCase):
|
||||||
behaviour eventually to still keep current rows.
|
behaviour eventually to still keep current rows.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
self.hs.config.stats_enabled = False
|
self.hs.config.stats.stats_enabled = False
|
||||||
self.handler.stats_enabled = False
|
self.handler.stats_enabled = False
|
||||||
|
|
||||||
u1 = self.register_user("u1", "pass")
|
u1 = self.register_user("u1", "pass")
|
||||||
|
@ -481,7 +481,7 @@ class StatsRoomTests(unittest.HomeserverTestCase):
|
||||||
self.assertIsNone(self._get_current_stats("room", r1))
|
self.assertIsNone(self._get_current_stats("room", r1))
|
||||||
self.assertIsNone(self._get_current_stats("user", u1))
|
self.assertIsNone(self._get_current_stats("user", u1))
|
||||||
|
|
||||||
self.hs.config.stats_enabled = True
|
self.hs.config.stats.stats_enabled = True
|
||||||
self.handler.stats_enabled = True
|
self.handler.stats_enabled = True
|
||||||
|
|
||||||
self._perform_background_initial_update()
|
self._perform_background_initial_update()
|
||||||
|
|
|
@ -451,7 +451,7 @@ class UserDirectoryTestCase(unittest.HomeserverTestCase):
|
||||||
visible.
|
visible.
|
||||||
"""
|
"""
|
||||||
self.handler.search_all_users = True
|
self.handler.search_all_users = True
|
||||||
self.hs.config.user_directory_search_all_users = True
|
self.hs.config.userdirectory.user_directory_search_all_users = True
|
||||||
|
|
||||||
u1 = self.register_user("user1", "pass")
|
u1 = self.register_user("user1", "pass")
|
||||||
self.register_user("user2", "pass")
|
self.register_user("user2", "pass")
|
||||||
|
@ -607,7 +607,7 @@ class TestUserDirSearchDisabled(unittest.HomeserverTestCase):
|
||||||
return hs
|
return hs
|
||||||
|
|
||||||
def test_disabling_room_list(self):
|
def test_disabling_room_list(self):
|
||||||
self.config.user_directory_search_enabled = True
|
self.config.userdirectory.user_directory_search_enabled = True
|
||||||
|
|
||||||
# First we create a room with another user so that user dir is non-empty
|
# First we create a room with another user so that user dir is non-empty
|
||||||
# for our user
|
# for our user
|
||||||
|
@ -624,7 +624,7 @@ class TestUserDirSearchDisabled(unittest.HomeserverTestCase):
|
||||||
self.assertTrue(len(channel.json_body["results"]) > 0)
|
self.assertTrue(len(channel.json_body["results"]) > 0)
|
||||||
|
|
||||||
# Disable user directory and check search returns nothing
|
# Disable user directory and check search returns nothing
|
||||||
self.config.user_directory_search_enabled = False
|
self.config.userdirectory.user_directory_search_enabled = False
|
||||||
channel = self.make_request(
|
channel = self.make_request(
|
||||||
"POST", b"user_directory/search", b'{"search_term":"user2"}'
|
"POST", b"user_directory/search", b'{"search_term":"user2"}'
|
||||||
)
|
)
|
||||||
|
|
|
@ -43,7 +43,7 @@ class DeleteMediaByIDTestCase(unittest.HomeserverTestCase):
|
||||||
self.admin_user = self.register_user("admin", "pass", admin=True)
|
self.admin_user = self.register_user("admin", "pass", admin=True)
|
||||||
self.admin_user_tok = self.login("admin", "pass")
|
self.admin_user_tok = self.login("admin", "pass")
|
||||||
|
|
||||||
self.filepaths = MediaFilePaths(hs.config.media_store_path)
|
self.filepaths = MediaFilePaths(hs.config.media.media_store_path)
|
||||||
|
|
||||||
def test_no_auth(self):
|
def test_no_auth(self):
|
||||||
"""
|
"""
|
||||||
|
@ -200,7 +200,7 @@ class DeleteMediaByDateSizeTestCase(unittest.HomeserverTestCase):
|
||||||
self.admin_user = self.register_user("admin", "pass", admin=True)
|
self.admin_user = self.register_user("admin", "pass", admin=True)
|
||||||
self.admin_user_tok = self.login("admin", "pass")
|
self.admin_user_tok = self.login("admin", "pass")
|
||||||
|
|
||||||
self.filepaths = MediaFilePaths(hs.config.media_store_path)
|
self.filepaths = MediaFilePaths(hs.config.media.media_store_path)
|
||||||
self.url = "/_synapse/admin/v1/media/%s/delete" % self.server_name
|
self.url = "/_synapse/admin/v1/media/%s/delete" % self.server_name
|
||||||
|
|
||||||
def test_no_auth(self):
|
def test_no_auth(self):
|
||||||
|
|
|
@ -2473,7 +2473,7 @@ class UserMediaRestTestCase(unittest.HomeserverTestCase):
|
||||||
def prepare(self, reactor, clock, hs):
|
def prepare(self, reactor, clock, hs):
|
||||||
self.store = hs.get_datastore()
|
self.store = hs.get_datastore()
|
||||||
self.media_repo = hs.get_media_repository_resource()
|
self.media_repo = hs.get_media_repository_resource()
|
||||||
self.filepaths = MediaFilePaths(hs.config.media_store_path)
|
self.filepaths = MediaFilePaths(hs.config.media.media_store_path)
|
||||||
|
|
||||||
self.admin_user = self.register_user("admin", "pass", admin=True)
|
self.admin_user = self.register_user("admin", "pass", admin=True)
|
||||||
self.admin_user_tok = self.login("admin", "pass")
|
self.admin_user_tok = self.login("admin", "pass")
|
||||||
|
|
|
@ -53,7 +53,7 @@ class MediaStorageTests(unittest.HomeserverTestCase):
|
||||||
self.primary_base_path = os.path.join(self.test_dir, "primary")
|
self.primary_base_path = os.path.join(self.test_dir, "primary")
|
||||||
self.secondary_base_path = os.path.join(self.test_dir, "secondary")
|
self.secondary_base_path = os.path.join(self.test_dir, "secondary")
|
||||||
|
|
||||||
hs.config.media_store_path = self.primary_base_path
|
hs.config.media.media_store_path = self.primary_base_path
|
||||||
|
|
||||||
storage_providers = [FileStorageProviderBackend(hs, self.secondary_base_path)]
|
storage_providers = [FileStorageProviderBackend(hs, self.secondary_base_path)]
|
||||||
|
|
||||||
|
|
|
@ -326,7 +326,7 @@ class TestResourceLimitsServerNoticesWithRealRooms(unittest.HomeserverTestCase):
|
||||||
for event in events:
|
for event in events:
|
||||||
if (
|
if (
|
||||||
event["type"] == EventTypes.Message
|
event["type"] == EventTypes.Message
|
||||||
and event["sender"] == self.hs.config.server_notices_mxid
|
and event["sender"] == self.hs.config.servernotices.server_notices_mxid
|
||||||
):
|
):
|
||||||
notice_in_room = True
|
notice_in_room = True
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue