1
0

Compare commits

...

6 Commits

Author SHA1 Message Date
Eric Eastwood
cbd49b072a More specific changelog 2025-05-14 16:27:32 -05:00
Eric Eastwood
f871dcb116 Move back to original position 2025-05-14 15:40:29 -05:00
Eric Eastwood
b86a878db2 Fix lints 2025-05-14 15:39:22 -05:00
Eric Eastwood
0e7b6abb1e Merge branch 'develop' into madlittlemods/generic-root-config 2025-05-14 15:37:00 -05:00
Eric Eastwood
83458c2b33 Add changelog 2025-05-07 17:33:19 -05:00
Eric Eastwood
ffbdb9f2be Move specific Synapse config out of RootConfig 2025-05-07 17:27:47 -05:00
4 changed files with 29 additions and 22 deletions

1
changelog.d/18410.misc Normal file
View File

@@ -0,0 +1 @@
Move Synapse specific config out of `RootConfig` for the load/read config flow (not config generation).

View File

@@ -101,13 +101,6 @@ def format_config_error(e: ConfigError) -> Iterator[str]:
parent_e = parent_e.__cause__
# We split these messages out to allow packages to override with package
# specific instructions.
MISSING_REPORT_STATS_CONFIG_INSTRUCTIONS = """\
Please opt in or out of reporting homeserver usage statistics, by setting
the `report_stats` key in your config file to either True or False.
"""
MISSING_REPORT_STATS_SPIEL = """\
We would really appreciate it if you could help our project out by reporting
homeserver usage statistics from your homeserver. Your homeserver's server name,
@@ -118,11 +111,6 @@ a success, as well as to convince other networks that they should peer with us.
Thank you.
"""
MISSING_SERVER_NAME = """\
Missing mandatory `server_name` config option.
"""
CONFIG_FILE_HEADER = """\
# Configuration file for Synapse.
#
@@ -929,13 +917,6 @@ def read_config_files(config_files: Iterable[str]) -> Dict[str, Any]:
specified_config.update(yaml_config)
if "server_name" not in specified_config:
raise ConfigError(MISSING_SERVER_NAME)
if "report_stats" not in specified_config:
raise ConfigError(
MISSING_REPORT_STATS_CONFIG_INSTRUCTIONS + "\n" + MISSING_REPORT_STATS_SPIEL
)
return specified_config

View File

@@ -27,7 +27,12 @@ import attr
from synapse.types import JsonDict
from synapse.util.check_dependencies import check_requirements
from ._base import Config, ConfigError
from ._base import MISSING_REPORT_STATS_SPIEL, Config, ConfigError
MISSING_REPORT_STATS_CONFIG_INSTRUCTIONS = """\
Please opt in or out of reporting homeserver usage statistics, by setting
the `report_stats` key in your config file to either True or False.
"""
@attr.s
@@ -50,7 +55,17 @@ class MetricsConfig(Config):
def read_config(self, config: JsonDict, **kwargs: Any) -> None:
self.enable_metrics = config.get("enable_metrics", False)
self.report_stats = config.get("report_stats", None)
report_stats = config.get("report_stats", None)
if report_stats is None:
raise ConfigError(
MISSING_REPORT_STATS_CONFIG_INSTRUCTIONS
+ "\n"
+ MISSING_REPORT_STATS_SPIEL,
("report_stats",),
)
self.report_stats = report_stats
self.report_stats_endpoint = config.get(
"report_stats_endpoint", "https://matrix.org/report-usage-stats/push"
)

View File

@@ -49,6 +49,11 @@ Using direct TCP replication for workers is no longer supported.
Please see https://element-hq.github.io/synapse/latest/upgrade.html#direct-tcp-replication-is-no-longer-supported-migrate-to-redis
"""
MISSING_SERVER_NAME = """\
Missing mandatory `server_name` config option.
"""
# by default, we attempt to listen on both '::' *and* '0.0.0.0' because some OSes
# (Windows, macOS, other BSD/Linux where net.ipv6.bindv6only is set) will only listen
# on IPv6 when '::' is set.
@@ -295,9 +300,14 @@ class ServerConfig(Config):
section = "server"
def read_config(self, config: JsonDict, **kwargs: Any) -> None:
self.server_name = config["server_name"]
self.server_context = config.get("server_context", None)
server_name = config.get("server_name")
if server_name is None:
raise ConfigError(MISSING_SERVER_NAME, ("server_name",))
self.server_name = server_name
try:
parse_and_validate_server_name(self.server_name)
except ValueError as e: