fix(email): send WhatsApp notification when no new emails found

Previously digest and forward commands silently exited when inbox
was empty, leaving the user with no feedback after the initial
"processing..." confirmation.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-21 20:29:58 +00:00
parent 2dd5aee9a7
commit 30678e6abf
2 changed files with 8 additions and 4 deletions

View File

@@ -98,12 +98,14 @@ def run_digest():
print("📬 Verific emailuri necitite...") print("📬 Verific emailuri necitite...")
saved = save_unread_emails() saved = save_unread_emails()
owner_jid = get_owner_jid()
if not saved: if not saved:
print("Niciun email nou de procesat.") print("Niciun email nou de procesat.")
if not DRY_RUN:
send_whatsapp(owner_jid, "📭 Nu sunt emailuri noi.")
return return
owner_jid = get_owner_jid()
for result in saved: for result in saved:
if not result.get("ok"): if not result.get("ok"):
print(f"⚠️ Sărit: {result.get('error')}") print(f"⚠️ Sărit: {result.get('error')}")

View File

@@ -148,12 +148,14 @@ def run_forward():
print("Verific emailuri necitite...") print("Verific emailuri necitite...")
emails = fetch_unread_emails() emails = fetch_unread_emails()
owner_jid = get_owner_jid()
if not emails: if not emails:
print("Niciun email nou de procesat.") print("Niciun email nou de procesat.")
if not DRY_RUN:
send_whatsapp(owner_jid, "📭 Nu sunt emailuri noi.")
return return
owner_jid = get_owner_jid()
for em in emails: for em in emails:
subject = em['subject'] subject = em['subject']
print(f"Trimit: {subject}") print(f"Trimit: {subject}")