Simplify email subject handling and remove duplicate functions
- Remove send_success_email/send_error_email from email_sender.py - Centralize subject logic in tasks.py using _get_subject() - Use EMAIL_SUBJECT_SUCCESS and EMAIL_SUBJECT_ERROR with clear defaults - Ensure subject is always set and logged before sending
This commit is contained in:
+4
-16
@@ -164,22 +164,10 @@ def send_success_email(
|
||||
Subject is customizable via EMAIL_SUBJECT_SUCCESS.
|
||||
Falls back to a safe default if the env var is missing or blank.
|
||||
"""
|
||||
# Read subject from environment; never allow blank
|
||||
raw_subject = os.getenv("EMAIL_SUBJECT_SUCCESS")
|
||||
subject = (raw_subject or "").strip()
|
||||
|
||||
if not subject:
|
||||
subject = "ScrAIbe: Your transcript is ready"
|
||||
logger.info(
|
||||
"EMAIL_SUBJECT_SUCCESS not set or blank; using default subject: %s", subject
|
||||
)
|
||||
else:
|
||||
logger.info("Using EMAIL_SUBJECT_SUCCESS: %s", subject)
|
||||
|
||||
# Final guard: ensure subject is never empty
|
||||
if not subject:
|
||||
subject = "ScrAIbe: Your transcript is ready"
|
||||
logger.warning("Subject was empty after reading; forced default subject.")
|
||||
subject = _get_subject(
|
||||
"EMAIL_SUBJECT_SUCCESS",
|
||||
"ScrAIbe: Your transcript is ready",
|
||||
)
|
||||
|
||||
body = (
|
||||
"Hello,\n\n"
|
||||
|
||||
Reference in New Issue
Block a user