From 50f1595dcd886ba194156c9f75d98e41769a29e7 Mon Sep 17 00:00:00 2001 From: SouthFox Date: Tue, 11 Apr 2023 23:03:53 +0800 Subject: [PATCH] [fix] relates to outboxobject class --- app/boxes.py | 20 ++++++++++++-------- tests/test_inbox.py | 2 +- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/app/boxes.py b/app/boxes.py index 8a46ce9..00260e8 100644 --- a/app/boxes.py +++ b/app/boxes.py @@ -47,8 +47,8 @@ async def get_outbox_object( select(OutboxObject) .where(OutboxObject.ap_id == ap_id) .options( - joinedload(OutboxObject.relates_to_inbox_object).options( - joinedload(InboxObject.actor), + joinedload(models.OutboxObject.relates_to_inbox_object).options( + joinedload(models.InboxObject.actor), ), ) ) @@ -105,8 +105,8 @@ async def process_incoming( def build_object( object, - relates_to_inbox_object_id = None, - relates_to_outbox_object_id = None, + relates_to_inbox_object = None, + relates_to_outbox_object = None, ) -> InboxObject: inbox_object = models.InboxObject( actor_id=actor.id, @@ -119,8 +119,12 @@ async def process_incoming( ap_object=object, visibility=handle_visibility(object), activity_object_ap_id=object["actor"], - relates_to_inbox_object_id=relates_to_inbox_object_id, - relates_to_outbox_object_id=relates_to_outbox_object_id, + relates_to_inbox_object_id=relates_to_inbox_object.id + if relates_to_inbox_object + else None, + relates_to_outbox_object_id=relates_to_outbox_object.id + if relates_to_outbox_object + else None, ) return inbox_object @@ -169,8 +173,8 @@ async def process_incoming( elif "Announce" == ap_object["type"]: inbox_object = build_object( ap_object, - relates_to_inbox_object_id=relates_to_inbox_object, - relates_to_outbox_object_id=relates_to_outbox_object, + relates_to_inbox_object=relates_to_inbox_object, + relates_to_outbox_object=relates_to_outbox_object, ) db_session.add(inbox_object) await db_session.flush() diff --git a/tests/test_inbox.py b/tests/test_inbox.py index 572fa43..c806271 100644 --- a/tests/test_inbox.py +++ b/tests/test_inbox.py @@ -137,4 +137,4 @@ def test_inbox_announce_request( saved_note = db.execute(select(models.OutboxObject)).scalar_one() print(saved_note.ap_id) - assert saved_note.announces_count == 0 # TODO WIP + assert saved_note.announces_count == 1 # TODO WIP