Apply review polish to the digest send path (post-v0.1.0:76)
Non-blocking items from the v76 reviewer pass. No redeploy needed — the box runs
v76 and its happy path is unaffected; these ride the next build:
- digest_mailer.send_digest: when Gmail is enabled but no sender resolves
(CRM_DIGEST_SENDER unset and no admin email), raise NoTransport so the caller
returns a clear 400 instead of a generic 502.
- gmail_send.send_via_gmail: wrap OSError/URLError (timeout/DNS) as a RuntimeError
("Gmail API unreachable: ...") to match the HTTPError handling; include the
sender in the HTTPError message for debuggability.
- credentials.py: correct the now-stale GMAIL_COMPOSE_SCOPE comment (the digest
mailer sends with this scope; only outreach drafts never send).
- test_gmail_send.py: add the HTTPError->RuntimeError branch, default_sender DB
fallback (+None case + env override), and the send_digest SMTP-tag path.
19/19 backend tests green.
This commit is contained in:
@@ -52,6 +52,11 @@ def send_digest(conn, to_addrs, subject, body, sender_email=None):
|
||||
if t == "gmail-dwd":
|
||||
from email_integration import gmail_send
|
||||
sender = sender_email or default_sender(conn)
|
||||
if not sender:
|
||||
# Gmail IS available but we have nobody to send as — a config gap, not a
|
||||
# send failure. Surface it as NoTransport so the caller returns a clear 400.
|
||||
raise NoTransport("Gmail is enabled but no sender address is set: "
|
||||
"set CRM_DIGEST_SENDER or give an active admin an email.")
|
||||
result = gmail_send.send_via_gmail(sender, to_addrs, subject, body, conn=conn)
|
||||
result["transport"] = "gmail-dwd"
|
||||
return result
|
||||
|
||||
Reference in New Issue
Block a user