Compare commits

...

1 Commits

Author SHA1 Message Date
giles
14fbd59e7b 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 <noreply@anthropic.com>
2026-02-23 20:36:56 +00:00

View File

@@ -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,