From c2be8ba0532af25971b5e10afb8a964fc20b3ca3 Mon Sep 17 00:00:00 2001 From: Thomas Sileo Date: Wed, 29 Jun 2022 22:20:01 +0200 Subject: [PATCH] More fixes --- app/admin.py | 6 +++++- app/main.py | 8 +++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/app/admin.py b/app/admin.py index ffe6215..f23c53e 100644 --- a/app/admin.py +++ b/app/admin.py @@ -204,7 +204,11 @@ async def admin_inbox( await db_session.scalars( q.options( joinedload(models.InboxObject.relates_to_inbox_object), - joinedload(models.InboxObject.relates_to_outbox_object), + joinedload(models.InboxObject.relates_to_outbox_object).options( + joinedload( + models.OutboxObject.outbox_object_attachments + ).options(joinedload(models.OutboxObjectAttachment.upload)), + ), joinedload(models.InboxObject.actor), ) .order_by(models.InboxObject.ap_published_at.desc()) diff --git a/app/main.py b/app/main.py index 325e572..bee2c55 100644 --- a/app/main.py +++ b/app/main.py @@ -116,7 +116,13 @@ async def request_middleware(request, call_next): @app.middleware("http") async def add_security_headers(request: Request, call_next): - response = await call_next(request) + try: + response = await call_next(request) + except RuntimeError as exc: + # https://github.com/encode/starlette/discussions/1527#discussioncomment-2234702 + if await request.is_disconnected() and str(exc) == "No response returned.": + return Response(status_code=204) + response.headers["referrer-policy"] = "no-referrer, strict-origin-when-cross-origin" response.headers["x-content-type-options"] = "nosniff" response.headers["x-xss-protection"] = "1; mode=block"