Make admin notification recipients configurable via ADMIN_EMAILS
Previously the To/Cc addresses were hardcoded in notifier.py (Andrea, Barbara, Markus). This caused accidental emails to production contacts during testing. Changes: - New ADMIN_EMAILS env var: comma-separated list of addresses. First address → To; remaining addresses → Cc. - AdminNotifier now accepts admin_emails list; warns and skips if empty. - Removed hardcoded _INDOOR_EMAIL / _OUTDOOR_EMAIL / _ADMIN_CC_EMAIL constants and the _recipients_for() routing method. - Config.from_env() parses ADMIN_EMAILS into a list. - main.py passes config.admin_emails to AdminNotifier. - .env.example documents the new variable with production example. - Tests: fixture updated; TestRecipientsFor removed (routing gone). For testing: ADMIN_EMAILS=you@example.com For production: ADMIN_EMAILS=andrea.sigrist@gmx.net,baba.laeubli@gmail.com,spielgruppen@familien-verein.ch https://claude.ai/code/session_01HaUFs7SaLD5SoiuGCY27Tw
This commit is contained in:
+1
-21
@@ -15,30 +15,10 @@ def notifier():
|
||||
password="secret",
|
||||
use_tls=True,
|
||||
from_email="agent@example.com",
|
||||
admin_emails=["to@example.com", "cc1@example.com", "cc2@example.com"],
|
||||
)
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# _recipients_for
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
|
||||
class TestRecipientsFor:
|
||||
def test_indoor_only_recipients(self, notifier):
|
||||
recipients = notifier._recipients_for(["indoor"])
|
||||
assert any("andrea" in r.lower() or "sigrist" in r.lower() for r in recipients)
|
||||
|
||||
def test_outdoor_only_recipients(self, notifier):
|
||||
recipients = notifier._recipients_for(["outdoor"])
|
||||
assert any("baba.laeubli" in r.lower() for r in recipients)
|
||||
|
||||
def test_both_includes_both_leaders(self, notifier):
|
||||
recipients = notifier._recipients_for(["indoor", "outdoor"])
|
||||
joined = " ".join(recipients).lower()
|
||||
assert "andrea.sigrist" in joined
|
||||
assert "baba.laeubli" in joined
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# _format_types
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user