Fix AP blueprint cross-DB queries + harden Ghost sync init

AP blueprints (activitypub.py, ap_social.py) were querying federation
tables (ap_actor_profiles etc.) on g.s which points to the app's own DB
after the per-app split. Now uses g._ap_s backed by get_federation_session()
for non-federation apps.

Also hardens Ghost sync before_app_serving to catch/rollback on failure
instead of crashing the Hypercorn worker.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
giles
2026-02-25 14:06:42 +00:00
parent 97d2021a00
commit 094b6c55cd
10 changed files with 1855 additions and 37 deletions

View File

@@ -105,6 +105,16 @@ async def get_federation_session():
await sess.close()
def needs_federation_session() -> bool:
"""True when the federation DB is separate from the app's main DB."""
return DATABASE_URL_FEDERATION != DATABASE_URL
def create_federation_session() -> AsyncSession:
"""Create an unmanaged session targeting the federation database."""
return _FederationSession()
def register_db(app: Quart):
@app.before_request