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>
This commit is contained in:
@@ -44,9 +44,15 @@ def _build_activity_json(activity: APActivity, actor: ActorProfile, domain: str)
|
|||||||
|
|
||||||
obj = dict(activity.object_data or {})
|
obj = dict(activity.object_data or {})
|
||||||
|
|
||||||
# Object id MUST be on the actor's domain (Mastodon origin check).
|
# Rewrite activity ID to match the delivery domain so Mastodon's
|
||||||
# The post URL (e.g. blog.rose-ash.com/slug/) goes in "url" only.
|
# origin check passes (activity ID host must equal actor host).
|
||||||
object_id = activity.activity_id + "/object"
|
# 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":
|
if activity.activity_type == "Delete":
|
||||||
obj.setdefault("id", object_id)
|
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://www.w3.org/ns/activitystreams",
|
||||||
"https://w3id.org/security/v1",
|
"https://w3id.org/security/v1",
|
||||||
],
|
],
|
||||||
"id": activity.activity_id,
|
"id": activity_id,
|
||||||
"type": activity.activity_type,
|
"type": activity.activity_type,
|
||||||
"actor": actor_url,
|
"actor": actor_url,
|
||||||
"published": activity.published.isoformat() if activity.published else None,
|
"published": activity.published.isoformat() if activity.published else None,
|
||||||
|
|||||||
Reference in New Issue
Block a user