From 56aaee5558f52eeeac3846f6d17f465daf36336d Mon Sep 17 00:00:00 2001 From: GareArc Date: Mon, 17 Mar 2025 15:01:31 -0400 Subject: [PATCH 1/2] fix: wrong branding title --- api/services/feature_service.py | 8 ++++++++ api/tasks/mail_email_code_login.py | 4 ++-- api/tasks/mail_invite_member_task.py | 4 ++-- api/tasks/mail_reset_password_task.py | 4 ++-- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/api/services/feature_service.py b/api/services/feature_service.py index 404dbc46ac..8335159999 100644 --- a/api/services/feature_service.py +++ b/api/services/feature_service.py @@ -195,3 +195,11 @@ class FeatureService: if "expired_at" in license_info: features.license.expired_at = license_info["expiredAt"] + + @classmethod + def get_enterprise_application_title(cls): + branding = cls.get_system_features().get("branding", None) + application_title = "Dify" + if branding and branding.get("enabled", False): + application_title = branding.get("application_title", "Dify") + return application_title diff --git a/api/tasks/mail_email_code_login.py b/api/tasks/mail_email_code_login.py index 4bfaaca453..6c52b725dc 100644 --- a/api/tasks/mail_email_code_login.py +++ b/api/tasks/mail_email_code_login.py @@ -29,7 +29,7 @@ def send_email_code_login_mail_task(language: str, to: str, code: str): if language == "zh-Hans": template = "email_code_login_mail_template_zh-CN.html" if dify_config.ENTERPRISE_ENABLED: - application_title = FeatureService.get_system_features().get("application_title", "Dify") + application_title = FeatureService.get_enterprise_application_title() template = "without-brand/email_code_login_mail_template_zh-CN_enterprise.html" html_content = render_template(template, to=to, code=code, application_title=application_title) else: @@ -38,7 +38,7 @@ def send_email_code_login_mail_task(language: str, to: str, code: str): else: template = "email_code_login_mail_template_en-US.html" if dify_config.ENTERPRISE_ENABLED: - application_title = FeatureService.get_system_features().get("application_title", "Dify") + application_title = FeatureService.get_enterprise_application_title() template = "without-brand/email_code_login_mail_template_en-US_enterprise.html" html_content = render_template(template, to=to, code=code, application_title=application_title) else: diff --git a/api/tasks/mail_invite_member_task.py b/api/tasks/mail_invite_member_task.py index 92c8250586..836fc3f991 100644 --- a/api/tasks/mail_invite_member_task.py +++ b/api/tasks/mail_invite_member_task.py @@ -36,7 +36,7 @@ def send_invite_member_mail_task(language: str, to: str, token: str, inviter_nam if language == "zh-Hans": template = "invite_member_mail_template_zh-CN.html" if dify_config.ENTERPRISE_ENABLED: - application_title = FeatureService.get_system_features().get("application_title", "Dify") + application_title = FeatureService.get_enterprise_application_title() template = "without-brand/invite_member_mail_template_zh-CN.html" html_content = render_template( template, @@ -54,7 +54,7 @@ def send_invite_member_mail_task(language: str, to: str, token: str, inviter_nam else: template = "invite_member_mail_template_en-US.html" if dify_config.ENTERPRISE_ENABLED: - application_title = FeatureService.get_system_features().get("application_title", "Dify") + application_title = FeatureService.get_enterprise_application_title() template = "without-brand/invite_member_mail_template_en-US.html" html_content = render_template( template, diff --git a/api/tasks/mail_reset_password_task.py b/api/tasks/mail_reset_password_task.py index d892dbe345..37c6fa99e5 100644 --- a/api/tasks/mail_reset_password_task.py +++ b/api/tasks/mail_reset_password_task.py @@ -29,7 +29,7 @@ def send_reset_password_mail_task(language: str, to: str, code: str): if language == "zh-Hans": template = "reset_password_mail_template_zh-CN.html" if dify_config.ENTERPRISE_ENABLED: - application_title = FeatureService.get_system_features().get("application_title", "Dify") + application_title = FeatureService.get_enterprise_application_title() template = "without-brand/reset_password_mail_template_zh-CN.html" html_content = render_template(template, to=to, code=code, application_title=application_title) else: @@ -38,7 +38,7 @@ def send_reset_password_mail_task(language: str, to: str, code: str): else: template = "reset_password_mail_template_en-US.html" if dify_config.ENTERPRISE_ENABLED: - application_title = FeatureService.get_system_features().get("application_title", "Dify") + application_title = FeatureService.get_enterprise_application_title() template = "without-brand/reset_password_mail_template_en-US.html" html_content = render_template(template, to=to, code=code, application_title=application_title) else: From d38f2cb3809caa837fb03410b2eebd3fe0e876ea Mon Sep 17 00:00:00 2001 From: GareArc Date: Mon, 17 Mar 2025 15:34:28 -0400 Subject: [PATCH 2/2] fix: change subject title --- api/services/feature_service.py | 6 +++--- api/tasks/mail_invite_member_task.py | 6 ++++-- api/tasks/mail_reset_password_task.py | 6 ++++-- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/api/services/feature_service.py b/api/services/feature_service.py index 8335159999..1deed47d75 100644 --- a/api/services/feature_service.py +++ b/api/services/feature_service.py @@ -198,8 +198,8 @@ class FeatureService: @classmethod def get_enterprise_application_title(cls): - branding = cls.get_system_features().get("branding", None) + branding = cls.get_system_features().branding application_title = "Dify" - if branding and branding.get("enabled", False): - application_title = branding.get("application_title", "Dify") + if branding.enabled: + application_title = branding.application_title return application_title diff --git a/api/tasks/mail_invite_member_task.py b/api/tasks/mail_invite_member_task.py index 836fc3f991..0bb3b0dd68 100644 --- a/api/tasks/mail_invite_member_task.py +++ b/api/tasks/mail_invite_member_task.py @@ -46,11 +46,12 @@ def send_invite_member_mail_task(language: str, to: str, token: str, inviter_nam url=url, application_title=application_title, ) + mail.send(to=to, subject=f"立即加入 {application_title} 工作空间", html=html_content) else: html_content = render_template( template, to=to, inviter_name=inviter_name, workspace_name=workspace_name, url=url ) - mail.send(to=to, subject="立即加入 Dify 工作空间", html=html_content) + mail.send(to=to, subject="立即加入 Dify 工作空间", html=html_content) else: template = "invite_member_mail_template_en-US.html" if dify_config.ENTERPRISE_ENABLED: @@ -64,11 +65,12 @@ def send_invite_member_mail_task(language: str, to: str, token: str, inviter_nam url=url, application_title=application_title, ) + mail.send(to=to, subject=f"Join {application_title} Workspace Now", html=html_content) else: html_content = render_template( template, to=to, inviter_name=inviter_name, workspace_name=workspace_name, url=url ) - mail.send(to=to, subject="Join Dify Workspace Now", html=html_content) + mail.send(to=to, subject="Join Dify Workspace Now", html=html_content) end_at = time.perf_counter() logging.info( diff --git a/api/tasks/mail_reset_password_task.py b/api/tasks/mail_reset_password_task.py index 37c6fa99e5..b47813bc1c 100644 --- a/api/tasks/mail_reset_password_task.py +++ b/api/tasks/mail_reset_password_task.py @@ -32,18 +32,20 @@ def send_reset_password_mail_task(language: str, to: str, code: str): application_title = FeatureService.get_enterprise_application_title() template = "without-brand/reset_password_mail_template_zh-CN.html" html_content = render_template(template, to=to, code=code, application_title=application_title) + mail.send(to=to, subject=f"设置您的 {application_title} 密码", html=html_content) else: html_content = render_template(template, to=to, code=code) - mail.send(to=to, subject="设置您的 Dify 密码", html=html_content) + mail.send(to=to, subject="设置您的 Dify 密码", html=html_content) else: template = "reset_password_mail_template_en-US.html" if dify_config.ENTERPRISE_ENABLED: application_title = FeatureService.get_enterprise_application_title() template = "without-brand/reset_password_mail_template_en-US.html" html_content = render_template(template, to=to, code=code, application_title=application_title) + mail.send(to=to, subject=f"Set Your {application_title} Password", html=html_content) else: html_content = render_template(template, to=to, code=code) - mail.send(to=to, subject="Set Your Dify Password", html=html_content) + mail.send(to=to, subject="Set Your Dify Password", html=html_content) end_at = time.perf_counter() logging.info(