From 952b28ece787b5f79866ff4b0b81b411aa5e69cc Mon Sep 17 00:00:00 2001 From: Thomas Sileo Date: Thu, 7 Jul 2022 08:55:53 +0200 Subject: [PATCH] Fix admin outbox query --- app/boxes.py | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/app/boxes.py b/app/boxes.py index 90e70d7..be88b32 100644 --- a/app/boxes.py +++ b/app/boxes.py @@ -454,24 +454,28 @@ async def get_outbox_object_by_ap_id( db_session: AsyncSession, ap_id: str ) -> models.OutboxObject | None: return ( - await db_session.execute( - select(models.OutboxObject) - .where(models.OutboxObject.ap_id == ap_id) - .options( - joinedload(models.OutboxObject.outbox_object_attachments).options( - joinedload(models.OutboxObjectAttachment.upload) - ), - joinedload(models.OutboxObject.relates_to_inbox_object).options( - joinedload(models.InboxObject.actor), - ), - joinedload(models.OutboxObject.relates_to_outbox_object).options( + ( + await db_session.execute( + select(models.OutboxObject) + .where(models.OutboxObject.ap_id == ap_id) + .options( joinedload(models.OutboxObject.outbox_object_attachments).options( joinedload(models.OutboxObjectAttachment.upload) ), - ), + joinedload(models.OutboxObject.relates_to_inbox_object).options( + joinedload(models.InboxObject.actor), + ), + joinedload(models.OutboxObject.relates_to_outbox_object).options( + joinedload( + models.OutboxObject.outbox_object_attachments + ).options(joinedload(models.OutboxObjectAttachment.upload)), + ), + ) ) ) - ).scalar_one_or_none() # type: ignore + .unique() + .scalar_one_or_none() + ) # type: ignore async def get_anybox_object_by_ap_id(