feat(email): each account gets its own email, in its own zone (milestone 495)
Milestone 495 "Email goes to each account, in its own time zone", on the operator's ruling (System 156): notifications go to each user, times in their zone, defaults on, toggled per user or per role. - users.notify_alerts / notify_report (migration 0036): None follows the role's default, notify.<kind>.<role> in settings, all on to start. - mail.pick_recipients: active accounts that want the email and have an address mail can reach (an SSO placeholder like name@oidc is skipped and flagged), each in its own zone with no UTC beside it, then the Also send to addresses in their chosen zone with UTC beside. One copy per address, all over one SMTP connection. - Alerts, the weekly report and the test email (to you, in your zone, plus the typed addresses) send that way. The save-time smtp.tz capture is gone. - Notifications: a role × email table of defaults, who each email reaches and who can't be reached, and Also send to with its own zone, which starts as the first admin's to open the page. - Account page: your address and your two switches. Users: an Emailed column, and an admin sets an account's switches on its page. - The Alerts page counts the accounts it emails. zone_select macro and formatting.zones_by_region shared by Account and Notifications. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -168,3 +168,33 @@ def test_only_an_admin_reaches_users(app):
|
||||
assert (await client.post("/settings/users/new", headers=CSRF, form={})).status_code == 403
|
||||
|
||||
asyncio.run(_go())
|
||||
|
||||
|
||||
def test_an_account_sets_its_own_address_and_switches_and_an_admin_can_too(app):
|
||||
async def _go():
|
||||
viewer, vid = await _client(app, role="viewer")
|
||||
page = await (await viewer.get("/account/")).get_data(as_text=True)
|
||||
assert 'action="/account/email"' in page and "As for viewers (on)" in page
|
||||
|
||||
resp = await viewer.post("/account/email", headers=CSRF, form={
|
||||
"email": "nope@oidc", "notify_alerts": "off", "notify_report": ""})
|
||||
assert resp.status_code == 400 and "mail can reach" in await resp.get_data(as_text=True)
|
||||
address = f"v-{vid[:8]}@example.com"
|
||||
assert (await viewer.post("/account/email", headers=CSRF, form={
|
||||
"email": address, "notify_alerts": "off", "notify_report": ""})).status_code == 302
|
||||
me = await _user(app, vid)
|
||||
assert (me.email, me.notify_alerts, me.notify_report) == (address, False, None)
|
||||
assert [a for a, _ in await _audits(app, vid)] == ["account.email"]
|
||||
|
||||
admin, aid = await _client(app)
|
||||
resp = await admin.post(f"/settings/users/{vid}/email", headers=CSRF,
|
||||
form={"email": "ignored@example.com", "notify_alerts": "", "notify_report": "off"})
|
||||
assert resp.status_code == 302
|
||||
me = await _user(app, vid)
|
||||
assert (me.email, me.notify_alerts, me.notify_report) == (address, None, False) # address kept
|
||||
assert [a for a, _ in await _audits(app, aid)] == ["user.email_settings"]
|
||||
|
||||
page = await (await admin.get("/settings/notifications/")).get_data(as_text=True)
|
||||
assert "Who gets email" in page and 'name="notify.alerts.viewer"' in page and "Also send to" in page
|
||||
|
||||
asyncio.run(_go())
|
||||
|
||||
Reference in New Issue
Block a user