This repository has been archived by the owner on Apr 26, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Ship the email templates as package_data #4052
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
Ship the example email templates as part of the package | ||
|
||
**Note**: if you deploy your Synapse instance from a git checkout or a github | ||
snapshot URL, then this means that the example email templates will no longer | ||
be installed in `res/templates`. If you have email notifications enabled, you | ||
should ensure that `email.template_dir` is either configured to point at a | ||
directory where you have installed customised templates, or leave it unset to | ||
use the default templates. | ||
|
||
The configuration parser will try to detect the situation where | ||
`email.template_dir` is incorrectly set to `res/templates` and do the right | ||
thing, but will warn about this. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,11 +13,19 @@ | |
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
from __future__ import print_function | ||
|
||
# This file can't be called email.py because if it is, we cannot: | ||
import email.utils | ||
import logging | ||
import os | ||
import sys | ||
import textwrap | ||
|
||
from ._base import Config | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
class EmailConfig(Config): | ||
def read_config(self, config): | ||
|
@@ -38,7 +46,6 @@ def read_config(self, config): | |
"smtp_host", | ||
"smtp_port", | ||
"notif_from", | ||
"template_dir", | ||
"notif_template_html", | ||
"notif_template_text", | ||
] | ||
|
@@ -62,9 +69,27 @@ def read_config(self, config): | |
self.email_smtp_host = email_config["smtp_host"] | ||
self.email_smtp_port = email_config["smtp_port"] | ||
self.email_notif_from = email_config["notif_from"] | ||
self.email_template_dir = email_config["template_dir"] | ||
self.email_notif_template_html = email_config["notif_template_html"] | ||
self.email_notif_template_text = email_config["notif_template_text"] | ||
|
||
self.email_template_dir = email_config.get("template_dir") | ||
|
||
# backwards-compatibility hack | ||
if ( | ||
self.email_template_dir == "res/templates" | ||
and not os.path.isfile( | ||
os.path.join(self.email_template_dir, self.email_notif_template_text) | ||
) | ||
): | ||
t = """\ | ||
WARNING: The email notifier is configured to look for templates in '%s', but no templates | ||
could be found there. We will fall back to using the example templates; to get rid of this | ||
warning, leave 'email.template_dir' unset. | ||
""" % (self.email_template_dir,) | ||
|
||
print(textwrap.fill(t, width=80) + "\n", file=sys.stderr) | ||
self.email_template_dir = None | ||
|
||
self.email_notif_for_new_users = email_config.get( | ||
"notif_for_new_users", True | ||
) | ||
|
@@ -113,7 +138,9 @@ def default_config(self, config_dir_path, server_name, **kwargs): | |
# require_transport_security: False | ||
# notif_from: "Your Friendly %(app)s Home Server <[email protected]>" | ||
# app_name: Matrix | ||
# template_dir: res/templates | ||
# # if template_dir is unset, uses the example templates that are part of | ||
# # the Synapse distribution. | ||
# #template_dir: res/templates | ||
# notif_template_html: notif_mail.html | ||
# notif_template_text: notif_mail.txt | ||
# notif_for_new_users: True | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(I'd rather these big blocks of text were defined at the top of the file as constants, rather than stomping all over the indentation)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fair