feat: add branding support

This commit is contained in:
GareArc
2025-03-11 07:14:52 -04:00
parent 0856792a57
commit fdb1e649d4
5 changed files with 50 additions and 6 deletions

View File

@ -5,6 +5,7 @@ import click
from celery import shared_task # type: ignore
from flask import render_template
from configs import dify_config
from extensions.ext_mail import mail
@ -25,10 +26,16 @@ def send_email_code_login_mail_task(language: str, to: str, code: str):
# send email code login mail using different languages
try:
if language == "zh-Hans":
html_content = render_template("email_code_login_mail_template_zh-CN.html", to=to, code=code)
template = "email_code_login_mail_template_zh-CN.html"
if dify_config.ENTERPRISE_ENABLED:
template = "without-brand/email_code_login_mail_template_zh-CN_enterprise.html"
html_content = render_template(template, to=to, code=code)
mail.send(to=to, subject="邮箱验证码", html=html_content)
else:
html_content = render_template("email_code_login_mail_template_en-US.html", to=to, code=code)
template = "email_code_login_mail_template_en-US.html"
if dify_config.ENTERPRISE_ENABLED:
template = "without-brand/email_code_login_mail_template_en-US_enterprise.html"
html_content = render_template(template, to=to, code=code)
mail.send(to=to, subject="Email Code", html=html_content)
end_at = time.perf_counter()

View File

@ -33,8 +33,11 @@ def send_invite_member_mail_task(language: str, to: str, token: str, inviter_nam
try:
url = f"{dify_config.CONSOLE_WEB_URL}/activate?token={token}"
if language == "zh-Hans":
template = "invite_member_mail_template_zh-CN.html"
if dify_config.ENTERPRISE_ENABLED:
template = "without-brand/invite_member_mail_template_zh-CN.html"
html_content = render_template(
"invite_member_mail_template_zh-CN.html",
template,
to=to,
inviter_name=inviter_name,
workspace_name=workspace_name,
@ -42,8 +45,11 @@ def send_invite_member_mail_task(language: str, to: str, token: str, inviter_nam
)
mail.send(to=to, subject="立即加入 Dify 工作空间", html=html_content)
else:
template = "invite_member_mail_template_en-US.html"
if dify_config.ENTERPRISE_ENABLED:
template = "without-brand/invite_member_mail_template_en-US.html"
html_content = render_template(
"invite_member_mail_template_en-US.html",
template,
to=to,
inviter_name=inviter_name,
workspace_name=workspace_name,

View File

@ -5,6 +5,7 @@ import click
from celery import shared_task # type: ignore
from flask import render_template
from configs import dify_config
from extensions.ext_mail import mail
@ -25,10 +26,16 @@ def send_reset_password_mail_task(language: str, to: str, code: str):
# send reset password mail using different languages
try:
if language == "zh-Hans":
html_content = render_template("reset_password_mail_template_zh-CN.html", to=to, code=code)
template = "reset_password_mail_template_zh-CN.html"
if dify_config.ENTERPRISE_ENABLED:
template = "without-brand/reset_password_mail_template_zh-CN.html"
html_content = render_template(template, to=to, code=code)
mail.send(to=to, subject="设置您的 Dify 密码", html=html_content)
else:
html_content = render_template("reset_password_mail_template_en-US.html", to=to, code=code)
template = "reset_password_mail_template_en-US.html"
if dify_config.ENTERPRISE_ENABLED:
template = "without-brand/reset_password_mail_template_en-US.html"
html_content = render_template(template, to=to, code=code)
mail.send(to=to, subject="Set Your Dify Password", html=html_content)
end_at = time.perf_counter()