diff --git a/api/controllers/console/workspace/account.py b/api/controllers/console/workspace/account.py index a1b7a554674cac..f1ec0f3d298db3 100644 --- a/api/controllers/console/workspace/account.py +++ b/api/controllers/console/workspace/account.py @@ -252,7 +252,7 @@ def get(self): account = current_user token, code = AccountService.generate_account_deletion_verification_code(account) - AccountService.send_account_delete_verification_email(account, code) + AccountService.send_account_deletion_verification_email(account, code) return {"result": "success", "data": token} diff --git a/api/services/account_service.py b/api/services/account_service.py index d95b5451057355..b891e8b1f1d4bc 100644 --- a/api/services/account_service.py +++ b/api/services/account_service.py @@ -262,13 +262,13 @@ def generate_account_deletion_verification_code(account: Account) -> tuple[str, @classmethod def send_account_deletion_verification_email(cls, account: Account, code: str): - language, email = account.interface_language, account.email + email = account.email if cls.email_code_account_deletion_rate_limiter.is_rate_limited(email): from controllers.console.auth.error import EmailCodeAccountDeletionRateLimitExceededError raise EmailCodeAccountDeletionRateLimitExceededError() - send_account_deletion_verification_code.delay(language=language, to=email, code=code) + send_account_deletion_verification_code.delay(to=email, code=code) cls.email_code_account_deletion_rate_limiter.increment_rate_limit(email) @@ -423,11 +423,6 @@ def revoke_reset_password_token(cls, token: str): def get_reset_password_data(cls, token: str) -> Optional[dict[str, Any]]: return TokenManager.get_token_data(token, "reset_password") - @classmethod - def send_account_delete_verification_email(cls, account: Account, code: str): - language, email = account.interface_language, account.email - send_account_deletion_verification_code.delay(language=language, to=email, code=code) - @classmethod def send_email_code_login_email( cls, account: Optional[Account] = None, email: Optional[str] = None, language: Optional[str] = "en-US" diff --git a/api/tasks/delete_account_task.py b/api/tasks/delete_account_task.py index 884918dc8b43a5..52c884ca29e3dc 100644 --- a/api/tasks/delete_account_task.py +++ b/api/tasks/delete_account_task.py @@ -23,4 +23,4 @@ def delete_account_task(account_id): logger.error(f"Account {account_id} not found.") return # send success email - send_deletion_success_task.delay(account.interface_language, account.email) + send_deletion_success_task.delay(account.email) diff --git a/api/tasks/mail_account_deletion_task.py b/api/tasks/mail_account_deletion_task.py index 8d1434dc55098e..49a3a6d280c1c9 100644 --- a/api/tasks/mail_account_deletion_task.py +++ b/api/tasks/mail_account_deletion_task.py @@ -9,7 +9,7 @@ @shared_task(queue="mail") -def send_deletion_success_task(language, to): +def send_deletion_success_task(to): """Send email to user regarding account deletion. Args: @@ -22,20 +22,12 @@ def send_deletion_success_task(language, to): start_at = time.perf_counter() try: - if language == "zh-Hans": - html_content = render_template( - "delete_account_success_template_zh-CN.html", - to=to, - email=to, - ) - mail.send(to=to, subject="Dify 账户删除成功", html=html_content) - else: - html_content = render_template( - "delete_account_success_template_en-US.html", - to=to, - email=to, - ) - mail.send(to=to, subject="Dify Account Deleted", html=html_content) + html_content = render_template( + "delete_account_success_template_en-US.html", + to=to, + email=to, + ) + mail.send(to=to, subject="Your Dify.AI Account Has Been Successfully Deleted", html=html_content) end_at = time.perf_counter() logging.info( @@ -48,7 +40,7 @@ def send_deletion_success_task(language, to): @shared_task(queue="mail") -def send_account_deletion_verification_code(language, to, code): +def send_account_deletion_verification_code(to, code): """Send email to user regarding account deletion verification code. Args: @@ -62,12 +54,8 @@ def send_account_deletion_verification_code(language, to, code): start_at = time.perf_counter() try: - if language == "zh-Hans": - html_content = render_template("delete_account_code_email_template_zh-CN.html", to=to, code=code) - mail.send(to=to, subject="Dify 的删除账户验证码", html=html_content) - else: - html_content = render_template("delete_account_code_email_en-US.html", to=to, code=code) - mail.send(to=to, subject="Delete Your Dify Account", html=html_content) + html_content = render_template("delete_account_code_email_template_en-US.html", to=to, code=code) + mail.send(to=to, subject="Dify.AI Account Deletion and Verification", html=html_content) end_at = time.perf_counter() logging.info(