Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Commit 8c9e723

Browse files
authored
Add a warning when using deprecated template_dir settings (#10768)
The deprecation itself happened in #10596 which shipped with Synapse v1.41.0. However, it doesn't seem fair to suddenly drop support for these settings in ~4-6w without being more vocal about said deprecation.
1 parent ae3c163 commit 8c9e723

File tree

4 files changed

+42
-0
lines changed

4 files changed

+42
-0
lines changed

changelog.d/10768.misc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Print a warning when using one of the deprecated `template_dir` settings.

synapse/config/account_validity.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,20 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14+
import logging
15+
1416
from synapse.config._base import Config, ConfigError
1517

18+
logger = logging.getLogger(__name__)
19+
20+
LEGACY_TEMPLATE_DIR_WARNING = """
21+
This server's configuration file is using the deprecated 'template_dir' setting in the
22+
'account_validity' section. Support for this setting has been deprecated and will be
23+
removed in a future version of Synapse. Server admins should instead use the new
24+
'custom_templates_directory' setting documented here:
25+
https://matrix-org.github.io/synapse/latest/templates.html
26+
---------------------------------------------------------------------------------------"""
27+
1628

1729
class AccountValidityConfig(Config):
1830
section = "account_validity"
@@ -69,6 +81,8 @@ def read_config(self, config, **kwargs):
6981

7082
# Load account validity templates.
7183
account_validity_template_dir = account_validity_config.get("template_dir")
84+
if account_validity_template_dir is not None:
85+
logger.warning(LEGACY_TEMPLATE_DIR_WARNING)
7286

7387
account_renewed_template_filename = account_validity_config.get(
7488
"account_renewed_html_path", "account_renewed.html"

synapse/config/emailconfig.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
# This file can't be called email.py because if it is, we cannot:
1818
import email.utils
19+
import logging
1920
import os
2021
from enum import Enum
2122
from typing import Optional
@@ -24,6 +25,8 @@
2425

2526
from ._base import Config, ConfigError
2627

28+
logger = logging.getLogger(__name__)
29+
2730
MISSING_PASSWORD_RESET_CONFIG_ERROR = """\
2831
Password reset emails are enabled on this homeserver due to a partial
2932
'email' block. However, the following required keys are missing:
@@ -44,6 +47,14 @@
4447
"email_validation": "[%(server_name)s] Validate your email",
4548
}
4649

50+
LEGACY_TEMPLATE_DIR_WARNING = """
51+
This server's configuration file is using the deprecated 'template_dir' setting in the
52+
'email' section. Support for this setting has been deprecated and will be removed in a
53+
future version of Synapse. Server admins should instead use the new
54+
'custom_templates_directory' setting documented here:
55+
https://matrix-org.github.io/synapse/latest/templates.html
56+
---------------------------------------------------------------------------------------"""
57+
4758

4859
@attr.s(slots=True, frozen=True)
4960
class EmailSubjectConfig:
@@ -105,6 +116,9 @@ def read_config(self, config, **kwargs):
105116

106117
# A user-configurable template directory
107118
template_dir = email_config.get("template_dir")
119+
if template_dir is not None:
120+
logger.warning(LEGACY_TEMPLATE_DIR_WARNING)
121+
108122
if isinstance(template_dir, str):
109123
# We need an absolute path, because we change directory after starting (and
110124
# we don't yet know what auxiliary templates like mail.css we will need).

synapse/config/sso.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,23 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14+
import logging
1415
from typing import Any, Dict, Optional
1516

1617
import attr
1718

1819
from ._base import Config
1920

21+
logger = logging.getLogger(__name__)
22+
23+
LEGACY_TEMPLATE_DIR_WARNING = """
24+
This server's configuration file is using the deprecated 'template_dir' setting in the
25+
'sso' section. Support for this setting has been deprecated and will be removed in a
26+
future version of Synapse. Server admins should instead use the new
27+
'custom_templates_directory' setting documented here:
28+
https://matrix-org.github.io/synapse/latest/templates.html
29+
---------------------------------------------------------------------------------------"""
30+
2031

2132
@attr.s(frozen=True)
2233
class SsoAttributeRequirement:
@@ -43,6 +54,8 @@ def read_config(self, config, **kwargs):
4354

4455
# The sso-specific template_dir
4556
self.sso_template_dir = sso_config.get("template_dir")
57+
if self.sso_template_dir is not None:
58+
logger.warning(LEGACY_TEMPLATE_DIR_WARNING)
4659

4760
# Read templates from disk
4861
custom_template_directories = (

0 commit comments

Comments
 (0)