From a006ba2cc4b7908dfe974a3dc9e29b0c9994d763 Mon Sep 17 00:00:00 2001 From: Thomas Sileo Date: Wed, 27 Jul 2022 18:50:10 +0200 Subject: [PATCH] Fix processing for forwarded transient activities --- app/activitypub.py | 2 +- app/boxes.py | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/activitypub.py b/app/activitypub.py index b48bc9e..512c19b 100644 --- a/app/activitypub.py +++ b/app/activitypub.py @@ -240,7 +240,7 @@ def object_visibility(ap_activity: RawObject, actor: "Actor") -> VisibilityEnum: def get_actor_id(activity: RawObject) -> str: - if activity["type"] in ["Note", "Article", "Video", "Question", "Page"]: + if "attributedTo" in activity: attributed_to = as_list(activity["attributedTo"]) return get_id(attributed_to[0]) else: diff --git a/app/boxes.py b/app/boxes.py index 0bdd1a1..c5d1f24 100644 --- a/app/boxes.py +++ b/app/boxes.py @@ -1239,6 +1239,12 @@ async def save_to_inbox( except Exception: raise fastapi.HTTPException(status_code=401, detail="Invalid LD sig") + # Transient activities from Mastodon like Like are not fetchable and + # will return the actor instead + if raw_object["id"] != raw_object_id: + logger.info(f"Unable to fetch {raw_object_id}") + return None + if ( await db_session.scalar( select(func.count(models.InboxObject.id)).where(