Add unpublish (Delete) support + improve object IDs
- on_post_unpublished handler sends Delete/Tombstone activity - Create/Update objects use post URL as id (for Delete reference) - Delete objects use Tombstone type Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -27,10 +27,16 @@ def _build_activity_json(activity: APActivity, actor: ActorProfile, domain: str)
|
||||
actor_url = f"https://{domain}/users/{username}"
|
||||
|
||||
obj = dict(activity.object_data or {})
|
||||
obj.setdefault("id", activity.activity_id + "/object")
|
||||
obj.setdefault("type", activity.object_type)
|
||||
obj.setdefault("attributedTo", actor_url)
|
||||
obj.setdefault("published", activity.published.isoformat() if activity.published else None)
|
||||
|
||||
if activity.activity_type == "Delete":
|
||||
# Delete: object is a Tombstone with just id + type
|
||||
obj.setdefault("type", "Tombstone")
|
||||
else:
|
||||
# Create/Update: full object with attribution
|
||||
obj.setdefault("id", obj.get("url") or (activity.activity_id + "/object"))
|
||||
obj.setdefault("type", activity.object_type)
|
||||
obj.setdefault("attributedTo", actor_url)
|
||||
obj.setdefault("published", activity.published.isoformat() if activity.published else None)
|
||||
|
||||
return {
|
||||
"@context": "https://www.w3.org/ns/activitystreams",
|
||||
|
||||
Reference in New Issue
Block a user