fix(settings): Notifications opens on first visit — no second begin on an autobegun session
CI / lint (push) Successful in 2s
CI / integration (push) Failing after 59s
CI / unit (push) Successful in 1m24s
CI / publish (push) Skipped

Reading the settings autobegins the session's transaction, so the
nested db.begin() that saves the first admin's zone as smtp.tz raised
InvalidRequestError and every visit 500'd until a zone was saved. The
integration test signed in without a zone, so that path never ran;
it now has a test of its own.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-08 15:34:19 -04:00
co-authored by Claude Opus 5.5
parent 22090b02d8
commit 7ae6f85032
2 changed files with 24 additions and 2 deletions
+3 -2
View File
@@ -222,8 +222,9 @@ async def notifications():
settings = await get_all_settings(db)
if not settings["smtp.tz"] and session.get("tz"):
# "Also send to" reads times in the first admin's zone until one is chosen.
async with db.begin():
await set_setting(db, "smtp.tz", session["tz"])
# Reading the settings already began this session's transaction.
await set_setting(db, "smtp.tz", session["tz"])
await db.commit()
settings["smtp.tz"] = session["tz"]
await _reload_app_config()
who = await audience(db)