From 14fbd59e7b8f62223fa5c0488549d73bbd8962ed Mon Sep 17 00:00:00 2001 From: giles Date: Mon, 23 Feb 2026 20:36:56 +0000 Subject: [PATCH] Fix activity ID domain mismatch in per-app delivery Mastodon requires the activity ID host to match the actor host. The stored activity_id uses federation.rose-ash.com but per-app delivery sends actor as blog.rose-ash.com etc. Rewrite the activity ID host to match the delivery domain. Co-Authored-By: Claude Opus 4.6 --- events/handlers/ap_delivery_handler.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/events/handlers/ap_delivery_handler.py b/events/handlers/ap_delivery_handler.py index 3c0bbe5..89260a7 100644 --- a/events/handlers/ap_delivery_handler.py +++ b/events/handlers/ap_delivery_handler.py @@ -44,9 +44,15 @@ def _build_activity_json(activity: APActivity, actor: ActorProfile, domain: str) obj = dict(activity.object_data or {}) - # Object id MUST be on the actor's domain (Mastodon origin check). - # The post URL (e.g. blog.rose-ash.com/slug/) goes in "url" only. - object_id = activity.activity_id + "/object" + # Rewrite activity ID to match the delivery domain so Mastodon's + # origin check passes (activity ID host must equal actor host). + # The stored activity_id uses the federation domain; we replace + # just the host portion for per-app delivery. + import re + activity_id = re.sub( + r"^https://[^/]+/", f"https://{domain}/", activity.activity_id, + ) + object_id = activity_id + "/object" if activity.activity_type == "Delete": obj.setdefault("id", object_id) @@ -67,7 +73,7 @@ def _build_activity_json(activity: APActivity, actor: ActorProfile, domain: str) "https://www.w3.org/ns/activitystreams", "https://w3id.org/security/v1", ], - "id": activity.activity_id, + "id": activity_id, "type": activity.activity_type, "actor": actor_url, "published": activity.published.isoformat() if activity.published else None,