Inbox: intake and verified processing of follows (phase 2, step 4)
CI / validate-monitoring (push) Successful in 8s
CI / lint (push) Successful in 14s
CI / test (push) Successful in 1m57s
CI / images (push) Skipped
CI / assets (push) Skipped
CI / python-package (push) Skipped
CI / notify (push) Successful in 6s
CI / validate-monitoring (push) Successful in 8s
CI / lint (push) Successful in 14s
CI / test (push) Successful in 1m57s
CI / images (push) Skipped
CI / assets (push) Skipped
CI / python-package (push) Skipped
CI / notify (push) Successful in 6s
Intake (in the request, no network): size, content type and shape checks, blocked domains refused (403), duplicates acknowledged once, then stored and answered 202. Processing (federation.inbox worker task): - verify the HTTP signature with either scheme, as of when it arrived, using the cached key and refreshing the sender once on failure (key rotation); a deleted account's Delete still verifies from cache - the signer must be the activity's actor and the activity id must be on the actor's host - handlers: Follow (accept, or pending with manual approval; repeat follows re-accepted; blocked accounts rejected), Undo of a Follow (only by the same actor), Delete of an actor, Update of an actor; anything else recorded - items being processed are marked, retried on transient failures, re-queued if a worker dies, and pruned after 30 days Outgoing Accept/Reject/Block activities are stored with stable ids and queued per inbox for the delivery task (next step). Public activities are fetchable at /activities/<uuid>. Metrics for inbox activities and signature checks. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MK52BGoJbPhZ1vSFuKcGUW
This commit is contained in:
1 parent
c1a7dd0877
commit
f312c4b577
15 files changed
+1147
-60
No files matched your search
@@ -145,3 +145,35 @@ def ordered_collection(collection_id: str, total: int, items: list | None = None
|
||||
if items is not None:
|
||||
doc["orderedItems"] = items
|
||||
return doc
|
||||
|
||||
|
||||
def _response(kind: str, activity_id: str, actor_id: str, obj, to: str) -> dict:
|
||||
return {
|
||||
"@context": AS_CONTEXT,
|
||||
"id": activity_id,
|
||||
"type": kind,
|
||||
"actor": actor_id,
|
||||
"object": obj,
|
||||
"to": [to],
|
||||
}
|
||||
|
||||
|
||||
def accept(activity_id: str, actor_id: str, follow: dict) -> dict:
|
||||
"""Accept a Follow (the original Follow is embedded, as Mastodon expects)."""
|
||||
return _response("Accept", activity_id, actor_id, follow, follow["actor"])
|
||||
|
||||
|
||||
def reject(activity_id: str, actor_id: str, follow: dict) -> dict:
|
||||
"""Decline a follow request, or end an existing follow."""
|
||||
return _response("Reject", activity_id, actor_id, follow, follow["actor"])
|
||||
|
||||
|
||||
def block(activity_id: str, actor_id: str, blocked_actor: str) -> dict:
|
||||
return _response("Block", activity_id, actor_id, blocked_actor, blocked_actor)
|
||||
|
||||
|
||||
def object_id(value) -> str | None:
|
||||
"""An object's id, whether it's given inline (a dict) or as a bare URI."""
|
||||
if isinstance(value, dict):
|
||||
value = value.get("id")
|
||||
return value if isinstance(value, str) and value else None
|
||||
Reference in new issue
Block a user