diff --git a/scripts/setup/inline_email_css.py b/scripts/setup/inline_email_css.py index f0c26db00c..25ba26f619 100755 --- a/scripts/setup/inline_email_css.py +++ b/scripts/setup/inline_email_css.py @@ -29,12 +29,12 @@ def configure_cssutils() -> None: configure_cssutils() def inline_template(template_source_name: str) -> None: - os.makedirs(COMPILED_EMAIL_TEMPLATES_PATH, exist_ok=True) - template_name = template_source_name.split('.source.html')[0] - compiled_template_path = os.path.join(COMPILED_EMAIL_TEMPLATES_PATH, - template_name + ".html") template_path = os.path.join(EMAIL_TEMPLATES_PATH, template_source_name) + compiled_template_path = os.path.join(os.path.dirname(template_path), "compiled", + os.path.basename(template_name) + ".html") + + os.makedirs(os.path.dirname(compiled_template_path), exist_ok=True) with open(template_path) as template_source_file: template_str = template_source_file.read() diff --git a/templates/zerver/emails/.gitignore b/templates/zerver/emails/.gitignore index e3ca6473f7..429b77e996 100644 --- a/templates/zerver/emails/.gitignore +++ b/templates/zerver/emails/.gitignore @@ -1 +1,2 @@ compiled +custom diff --git a/zerver/lib/send_email.py b/zerver/lib/send_email.py index 97c75b139a..43f6653e81 100644 --- a/zerver/lib/send_email.py +++ b/zerver/lib/send_email.py @@ -265,12 +265,13 @@ def send_custom_email(users: List[UserProfile], options: Dict[str, Any]) -> None parsed_email_template = Parser(policy=default).parsestr(text) email_template_hash = hashlib.sha256(text.encode('utf-8')).hexdigest()[0:32] - email_filename = "custom_email_%s.source.html" % (email_template_hash,) - email_id = "zerver/emails/custom_email_%s" % (email_template_hash,) + email_filename = "custom/custom_email_%s.source.html" % (email_template_hash,) + email_id = "zerver/emails/custom/custom_email_%s" % (email_template_hash,) markdown_email_base_template_path = "templates/zerver/emails/custom_email_base.pre.html" html_source_template_path = "templates/%s.source.html" % (email_id,) plain_text_template_path = "templates/%s.txt" % (email_id,) subject_path = "templates/%s.subject.txt" % (email_id,) + os.makedirs(os.path.dirname(html_source_template_path), exist_ok=True) # First, we render the markdown input file just like our # user-facing docs with render_markdown_path.