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:
giles
2026-02-21 23:26:56 +00:00
parent a28add8640
commit 18410c4b16
2 changed files with 51 additions and 4 deletions

View File

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