fix: Ensure user language is activated when sending notifications

pull/15566/head
wangruidong 2025-06-11 16:14:20 +08:00 committed by 老广
parent e89f43dcd3
commit 4e7cd37c1d
1 changed files with 9 additions and 6 deletions

View File

@ -6,6 +6,7 @@ from common.tasks import send_mail_attachment_async, upload_backup_to_obj_storag
from notifications.notifications import UserMessage from notifications.notifications import UserMessage
from terminal.models.component.storage import ReplayStorage from terminal.models.component.storage import ReplayStorage
from users.models import User from users.models import User
from users.utils import activate_user_language
class AccountBackupExecutionTaskMsg: class AccountBackupExecutionTaskMsg:
@ -28,9 +29,10 @@ class AccountBackupExecutionTaskMsg:
).format(name) ).format(name)
def publish(self, attachment_list=None): def publish(self, attachment_list=None):
send_mail_attachment_async( with activate_user_language(self.user):
self.subject, self.message, [self.user.email], attachment_list send_mail_attachment_async(
) self.subject, self.message, [self.user.email], attachment_list
)
class AccountBackupByObjStorageExecutionTaskMsg: class AccountBackupByObjStorageExecutionTaskMsg:
@ -74,9 +76,10 @@ class ChangeSecretExecutionTaskMsg:
return self.summary + '\n' + default_message return self.summary + '\n' + default_message
def publish(self, attachments=None): def publish(self, attachments=None):
send_mail_attachment_async( with activate_user_language(self.user):
self.subject, self.message, [self.user.email], attachments send_mail_attachment_async(
) self.subject, self.message, [self.user.email], attachments
)
class GatherAccountChangeMsg(UserMessage): class GatherAccountChangeMsg(UserMessage):