From 567595bb4b7972a156e8efa60e5ac9d7557c622c Mon Sep 17 00:00:00 2001 From: Thomas Sileo Date: Tue, 13 Sep 2022 21:03:11 +0200 Subject: [PATCH] Tweak inbox processing --- app/boxes.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/app/boxes.py b/app/boxes.py index 95ed640..cda7ae0 100644 --- a/app/boxes.py +++ b/app/boxes.py @@ -1861,6 +1861,28 @@ async def save_to_inbox( raw_object: ap.RawObject, sent_by_ap_actor_id: str, ) -> None: + # Special case for server sending the actor as a payload (like python-federation) + if ap.as_list(raw_object["type"])[0] in ap.ACTOR_TYPES: + if ap.get_id(raw_object) == sent_by_ap_actor_id: + updated_actor = RemoteActor(raw_object) + + try: + actor = await fetch_actor(db_session, sent_by_ap_actor_id) + except ap.ObjectNotFoundError: + logger.warning("Actor not found") + return + + # Update the actor + actor.ap_actor = updated_actor.ap_actor + await db_session.commit() + return + + else: + logger.warning( + f"Reveived an actor payload {raw_object} from " f"{sent_by_ap_actor_id}" + ) + return + try: actor = await fetch_actor(db_session, ap.get_id(raw_object["actor"])) except ap.ObjectNotFoundError: