Add federation event handlers, AP delivery, and anchoring
Phase 3-5 of ActivityPub integration: - Federation handlers: post.published, calendar_entry.created, product.listed → publish_activity() for AP outbox - AP delivery handler: federation.activity_created → sign + POST to follower inboxes with HTTP Signatures - IPFS storage wired into publish_activity() (best-effort) - Anchoring utility: merkle trees + OpenTimestamps Bitcoin timestamping Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -158,7 +158,28 @@ class SqlFederationService:
|
||||
session.add(activity)
|
||||
await session.flush()
|
||||
|
||||
# Emit domain event for downstream processing (IPFS storage, delivery)
|
||||
# Store activity JSON on IPFS (best-effort — don't fail publish if IPFS down)
|
||||
try:
|
||||
from shared.utils.ipfs_client import add_json, is_available
|
||||
if await is_available():
|
||||
activity_json = {
|
||||
"@context": "https://www.w3.org/ns/activitystreams",
|
||||
"id": activity_uri,
|
||||
"type": activity_type,
|
||||
"actor": f"https://{domain}/users/{username}",
|
||||
"published": now.isoformat(),
|
||||
"object": {
|
||||
"type": object_type,
|
||||
**object_data,
|
||||
},
|
||||
}
|
||||
cid = await add_json(activity_json)
|
||||
activity.ipfs_cid = cid
|
||||
await session.flush()
|
||||
except Exception:
|
||||
pass # IPFS failure is non-fatal
|
||||
|
||||
# Emit domain event for downstream processing (delivery)
|
||||
from shared.events import emit_event
|
||||
await emit_event(
|
||||
session,
|
||||
|
||||
Reference in New Issue
Block a user