fix: use correct config reference for email alerts

This commit is contained in:
Денис Кривоченко
2026-07-31 01:12:28 +07:00
parent 974ecbb36d
commit 6c466dc0f6
+4 -3
View File
@@ -42,13 +42,13 @@ def _transcription_log_and_notify_email(action: str, error_details: str):
import smtplib import smtplib
from email.mime.text import MIMEText from email.mime.text import MIMEText
msg = MIMEMultipart() msg = MIMEMultipart()
msg['From'] = str(getattr(config.config, 'DEFAULT_EMAIL_FROM', 'bot@noreply.com')) msg['From'] = str(getattr(config, 'DEFAULT_EMAIL_FROM', 'bot@noreply.com'))
to_emails = getattr(config.config, 'ALERTS_SUPPORT_EMAILS', ['admin@example.com']) to_emails = getattr(config, 'ALERTS_SUPPORT_EMAILS', ['admin@example.com'])
msg['To'] = ', '.join(to_emails) if isinstance(to_emails, list) else str(to_emails) msg['To'] = ', '.join(to_emails) if isinstance(to_emails, list) else str(to_emails)
msg['Subject'] = f'TrueConf Bot Error: Транскрипция - {action}' msg['Subject'] = f'TrueConf Bot Error: Транскрипция - {action}'
body = f'Обнаружена ошибка в транскрипции.\nВремя: {timestamp}\nДействие: {action}\nДетали:\n{error_details}' body = f'Обнаружена ошибка в транскрипции.\nВремя: {timestamp}\nДействие: {action}\nДетали:\n{error_details}'
msg.attach(MIMEText(body, 'plain', 'utf-8')) msg.attach(MIMEText(body, 'plain', 'utf-8'))
with smtplib.SMTP(getattr(config.config, 'SMTP_SERVER', 'localhost'), int(getattr(config.config, 'SMTP_PORT', 25))) as server: with smtplib.SMTP(getattr(config, 'SMTP_SERVER', 'localhost'), int(getattr(config, 'SMTP_PORT', 25))) as server:
server.send_message(msg) server.send_message(msg)
except Exception: except Exception:
pass pass
@@ -163,3 +163,4 @@ async def transcription_handler(msg: Message):