Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion scripts-dev/update_database
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class MockHomeserver(HomeServer):

def __init__(self, config, **kwargs):
super(MockHomeserver, self).__init__(
config.server_name, reactor=reactor, config=config, **kwargs
config.server.server_name, reactor=reactor, config=config, **kwargs
)

self.version_string = "Synapse/" + get_version_string(synapse)
Expand Down
4 changes: 2 additions & 2 deletions scripts/synapse_port_db
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ class MockHomeserver:
def __init__(self, config):
self.clock = Clock(reactor)
self.config = config
self.hostname = config.server_name
self.hostname = config.server.server_name
self.version_string = "Synapse/" + get_version_string(synapse)

def get_clock(self):
Expand Down Expand Up @@ -583,7 +583,7 @@ class Porter(object):
return

self.postgres_store = self.build_db_store(
self.hs_config.get_single_database()
self.hs_config.database.get_single_database()
)

await self.run_background_updates_on_postgres()
Expand Down
2 changes: 1 addition & 1 deletion synapse/app/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ def refresh_certificate(hs):
if not hs.config.server.has_tls_listener():
return

hs.config.read_certificate_from_disk()
hs.config.tls.read_certificate_from_disk()
hs.tls_server_context_factory = context_factory.ServerContextFactory(hs.config)

if hs._listening_services:
Expand Down
4 changes: 2 additions & 2 deletions synapse/app/admin_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,9 @@ def start(config_options):
# Explicitly disable background processes
config.server.update_user_directory = False
config.worker.run_background_tasks = False
config.start_pushers = False
config.worker.start_pushers = False
config.pusher_shard_config.instances = []
config.send_federation = False
config.worker.send_federation = False
config.federation_shard_config.instances = []

synapse.events.USE_FROZEN_DICTS = config.server.use_frozen_dicts
Expand Down
2 changes: 1 addition & 1 deletion synapse/app/homeserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ def _configure_named_resource(self, name, compress=False):
)

if name in ["media", "federation", "client"]:
if self.config.media.enable_media_repo:
if self.config.server.enable_media_repo:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I might be missing context here, but why was this line (wrongly) trying to get the setting from the media config? Ditto for the account_validity vs email config.

Also, and not something that needs to be fixed now, I find it a bit worrying if we have been looking for this setting in the wrong config class for some time and CI didn't pick it up.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I might be missing context here, but why was this line (wrongly) trying to get the setting from the media config? Ditto for the account_validity vs email config.

In one of the previous PRs I updated it to look at the wrong configuration.

Also, and not something that needs to be fixed now, I find it a bit worrying if we have been looking for this setting in the wrong config class for some time and CI didn't pick it up.

It still worked fine before this PR, which is why CI didn't pick it up. It is due to this code:

def __getattr__(self, item: str) -> Any:
"""
Try and fetch a configuration option that does not exist on this class.
This is so that existing configs that rely on `self.value`, where value
is actually from a different config section, continue to work.
"""
if item in ["generate_config_section", "read_config"]:
raise AttributeError(item)
if self.root is None:
raise AttributeError(item)
else:
return self.root._get_unclassed_config(self.section, item)

(Which I need to double check is removed by this PR actually...)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, I removed that! 🎉

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it, thanks!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It took me a bit to figure out how this could possibly have worked, it's quite confusing! Glad we're getting rid of it....

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah definitely...

media_repo = self.get_media_repository_resource()
resources.update(
{MEDIA_PREFIX: media_repo, LEGACY_MEDIA_PREFIX: media_repo}
Expand Down
8 changes: 2 additions & 6 deletions synapse/handlers/account_validity.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,8 @@ def __init__(self, hs: "HomeServer"):
and self._account_validity_renew_by_email_enabled
):
# Don't do email-specific configuration if renewal by email is disabled.
self._template_html = (
hs.config.account_validity.account_validity_template_html
)
self._template_text = (
hs.config.account_validity.account_validity_template_text
)
self._template_html = hs.config.email.account_validity_template_html
self._template_text = hs.config.email.account_validity_template_text
self._renew_email_subject = (
hs.config.account_validity.account_validity_renew_email_subject
)
Expand Down
7 changes: 5 additions & 2 deletions synapse/handlers/room_member.py
Original file line number Diff line number Diff line change
Expand Up @@ -1468,8 +1468,11 @@ async def _remote_join(
if len(remote_room_hosts) == 0:
raise SynapseError(404, "No known servers")

check_complexity = self.hs.config.limit_remote_rooms.enabled
if check_complexity and self.hs.config.limit_remote_rooms.admins_can_join:
check_complexity = self.hs.config.server.limit_remote_rooms.enabled
if (
check_complexity
and self.hs.config.server.limit_remote_rooms.admins_can_join
):
check_complexity = not await self.auth.is_server_admin(user)

if check_complexity:
Expand Down
2 changes: 1 addition & 1 deletion synapse/replication/tcp/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def __init__(self, hs: "HomeServer"):
self._instance_name = hs.get_instance_name()
self._typing_handler = hs.get_typing_handler()

self._notify_pushers = hs.config.start_pushers
self._notify_pushers = hs.config.worker.start_pushers
self._pusher_pool = hs.get_pusherpool()
self._presence_handler = hs.get_presence_handler()

Expand Down
7 changes: 5 additions & 2 deletions synapse/replication/tcp/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,10 @@ def __init__(self, hs: "HomeServer"):
if hs.config.worker.worker_app is not None:
continue

if stream.NAME == FederationStream.NAME and hs.config.send_federation:
if (
stream.NAME == FederationStream.NAME
and hs.config.worker.send_federation
):
# We only support federation stream if federation sending
# has been disabled on the master.
continue
Expand Down Expand Up @@ -225,7 +228,7 @@ def __init__(self, hs: "HomeServer"):
self._is_master = hs.config.worker.worker_app is None

self._federation_sender = None
if self._is_master and not hs.config.send_federation:
if self._is_master and not hs.config.worker.send_federation:
self._federation_sender = hs.get_federation_sender()

self._server_notices_sender = None
Expand Down
2 changes: 1 addition & 1 deletion synapse/rest/client/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def __init__(self, hs: "HomeServer"):
self.auth_handler = hs.get_auth_handler()
self.registration_handler = hs.get_registration_handler()
self.recaptcha_template = hs.config.captcha.recaptcha_template
self.terms_template = hs.config.terms_template
self.terms_template = hs.config.consent.terms_template
self.registration_token_template = (
hs.config.registration.registration_token_template
)
Expand Down
4 changes: 3 additions & 1 deletion synapse/rest/client/push_rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ def __init__(self, hs: "HomeServer"):
self.notifier = hs.get_notifier()
self._is_worker = hs.config.worker.worker_app is not None

self._users_new_default_push_rules = hs.config.users_new_default_push_rules
self._users_new_default_push_rules = (
hs.config.server.users_new_default_push_rules
)

async def on_PUT(self, request: SynapseRequest, path: str) -> Tuple[int, JsonDict]:
if self._is_worker:
Expand Down
4 changes: 3 additions & 1 deletion synapse/storage/databases/main/push_rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,9 @@ def __init__(self, database: DatabasePool, db_conn, hs):
prefilled_cache=push_rules_prefill,
)

self._users_new_default_push_rules = hs.config.users_new_default_push_rules
self._users_new_default_push_rules = (
hs.config.server.users_new_default_push_rules
)

@abc.abstractmethod
def get_max_push_rules_stream_id(self):
Expand Down
4 changes: 3 additions & 1 deletion synapse/storage/databases/main/registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -1778,7 +1778,9 @@ class RegistrationStore(StatsStore, RegistrationBackgroundUpdateStore):
def __init__(self, database: DatabasePool, db_conn: Connection, hs: "HomeServer"):
super().__init__(database, db_conn, hs)

self._ignore_unknown_session_error = hs.config.request_token_inhibit_3pid_errors
self._ignore_unknown_session_error = (
hs.config.server.request_token_inhibit_3pid_errors
)

self._access_tokens_id_gen = IdGenerator(db_conn, "access_tokens", "id")
self._refresh_tokens_id_gen = IdGenerator(db_conn, "refresh_tokens", "id")
Expand Down
12 changes: 8 additions & 4 deletions tests/config/test_load.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def test_generates_and_loads_macaroon_secret_key(self):

config = HomeServerConfig.load_config("", ["-c", self.file])
self.assertTrue(
hasattr(config, "macaroon_secret_key"),
hasattr(config.key, "macaroon_secret_key"),
"Want config to have attr macaroon_secret_key",
)
if len(config.key.macaroon_secret_key) < 5:
Expand All @@ -60,7 +60,7 @@ def test_generates_and_loads_macaroon_secret_key(self):

config = HomeServerConfig.load_or_generate_config("", ["-c", self.file])
self.assertTrue(
hasattr(config, "macaroon_secret_key"),
hasattr(config.key, "macaroon_secret_key"),
"Want config to have attr macaroon_secret_key",
)
if len(config.key.macaroon_secret_key) < 5:
Expand All @@ -74,8 +74,12 @@ def test_load_succeeds_if_macaroon_secret_key_missing(self):
config1 = HomeServerConfig.load_config("", ["-c", self.file])
config2 = HomeServerConfig.load_config("", ["-c", self.file])
config3 = HomeServerConfig.load_or_generate_config("", ["-c", self.file])
self.assertEqual(config1.macaroon_secret_key, config2.macaroon_secret_key)
self.assertEqual(config1.macaroon_secret_key, config3.macaroon_secret_key)
self.assertEqual(
config1.key.macaroon_secret_key, config2.key.macaroon_secret_key
)
self.assertEqual(
config1.key.macaroon_secret_key, config3.key.macaroon_secret_key
)

def test_disable_registration(self):
self.generate_config()
Expand Down
2 changes: 1 addition & 1 deletion tests/storage/test_appservice.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def setUp(self):
self.db_pool = database._db_pool
self.engine = database.engine

db_config = hs.config.get_single_database()
db_config = hs.config.database.get_single_database()
self.store = TestTransactionStore(
database, make_conn(db_config, self.engine, "test"), hs
)
Expand Down
2 changes: 1 addition & 1 deletion tests/storage/test_txn_limit.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def make_homeserver(self, reactor, clock):
return self.setup_test_homeserver(db_txn_limit=1000)

def test_config(self):
db_config = self.hs.config.get_single_database()
db_config = self.hs.config.database.get_single_database()
self.assertEqual(db_config.config["txn_limit"], 1000)

def test_select(self):
Expand Down