From 4e7cd37c1d477e3ff4c5e72778c4e8717f242d84 Mon Sep 17 00:00:00 2001 From: wangruidong <940853815@qq.com> Date: Wed, 11 Jun 2025 16:14:20 +0800 Subject: [PATCH] fix: Ensure user language is activated when sending notifications --- apps/accounts/notifications.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/apps/accounts/notifications.py b/apps/accounts/notifications.py index 4ab56963e..c8ec6db2e 100644 --- a/apps/accounts/notifications.py +++ b/apps/accounts/notifications.py @@ -6,6 +6,7 @@ from common.tasks import send_mail_attachment_async, upload_backup_to_obj_storag from notifications.notifications import UserMessage from terminal.models.component.storage import ReplayStorage from users.models import User +from users.utils import activate_user_language class AccountBackupExecutionTaskMsg: @@ -28,9 +29,10 @@ class AccountBackupExecutionTaskMsg: ).format(name) def publish(self, attachment_list=None): - send_mail_attachment_async( - self.subject, self.message, [self.user.email], attachment_list - ) + with activate_user_language(self.user): + send_mail_attachment_async( + self.subject, self.message, [self.user.email], attachment_list + ) class AccountBackupByObjStorageExecutionTaskMsg: @@ -74,9 +76,10 @@ class ChangeSecretExecutionTaskMsg: return self.summary + '\n' + default_message def publish(self, attachments=None): - send_mail_attachment_async( - self.subject, self.message, [self.user.email], attachments - ) + with activate_user_language(self.user): + send_mail_attachment_async( + self.subject, self.message, [self.user.email], attachments + ) class GatherAccountChangeMsg(UserMessage):