fix(settings): Notifications opens on first visit — no second begin on an autobegun session
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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user