feat(email): the report, invites, resets and test sends go through the outbox; only it talks SMTP (#5508)
#5508 "Every other email through the outbox: weekly report, invites, password resets, and the test buttons" (milestone 501). - outbox.send_each queues one email per reader (claimed, so the sender doesn't take it too) and tries them at once, for a page that answers with what happened; outbox.said words the result. attempt takes a cfg for a test of the form's unsaved settings and returns the settled rows. - Weekly report (scheduled and Send now) and invites: queued, tried at once; one the server couldn't take yet is retried for an hour. An invite that didn't go shows its link with the reason, as before. - Password reset: queued in the reset link's own transaction; the sender delivers it on its next tick. - Settings -> Notifications test email and a rule's Send test: queued and recorded with retry=False, tried once (System 156 ruling). - Removed mail.send, notifications._send_email and _smtp_send_sync; dispatch_notifications is webhook only. A guard asserts only the outbox (and smtp_open itself) opens an SMTP connection, with a self-test. Also fixes run 8941 (#5507's integration test): its Also-send-to addresses were "@test", which is_real_address rightly drops; they are example.com now. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -81,7 +81,7 @@ def test_alerts_in_one_window_are_one_email_and_each_event_records_it(app, monke
|
||||
from steward.core import outbox
|
||||
|
||||
tag = uuid.uuid4().hex[:8]
|
||||
extra = f"oncall-{tag}@test"
|
||||
extra = f"oncall-{tag}@example.com"
|
||||
app.config["SMTP"] = {"host": "mx.test", "port": 587, "from": "steward@test",
|
||||
"recipients": [extra], "tz": "America/New_York"}
|
||||
t0 = datetime(2026, 10, 9, 12, 0, tzinfo=timezone.utc)
|
||||
@@ -142,7 +142,7 @@ def test_an_email_whose_alerts_were_deleted_fails_and_says_so(app, monkeypatch):
|
||||
from steward.models.alerts import AlertEvent
|
||||
|
||||
tag = uuid.uuid4().hex[:8]
|
||||
extra = f"gone-{tag}@test"
|
||||
extra = f"gone-{tag}@example.com"
|
||||
app.config["SMTP"] = {"host": "mx.test", "port": 587, "from": "steward@test", "recipients": [extra]}
|
||||
monkeypatch.setattr(outbox, "deliver_sync", lambda cfg, msgs: [None] * len(msgs))
|
||||
t0 = datetime.now(timezone.utc)
|
||||
@@ -155,8 +155,8 @@ def test_an_email_whose_alerts_were_deleted_fails_and_says_so(app, monkeypatch):
|
||||
async with app.db_sessionmaker() as s:
|
||||
async with s.begin():
|
||||
await s.execute(delete(AlertEvent).where(AlertEvent.id == ev))
|
||||
states = await outbox.attempt(app, [row.id])
|
||||
return states[row.id], row.id
|
||||
done = await outbox.attempt(app, [row.id])
|
||||
return done[row.id].state, row.id
|
||||
|
||||
state, rid = asyncio.run(_go())
|
||||
assert state == "failed"
|
||||
|
||||
Reference in New Issue
Block a user