Federation tables for followers, inbox and deliveries (phase 2, step 3)
CI / validate-monitoring (push) Successful in 7s
CI / lint (push) Successful in 11s
CI / test (push) Successful in 1m42s
CI / images (push) Skipped
CI / assets (push) Skipped
CI / python-package (push) Skipped
CI / notify (push) Successful in 5s
CI / validate-monitoring (push) Successful in 7s
CI / lint (push) Successful in 11s
CI / test (push) Successful in 1m42s
CI / images (push) Skipped
CI / assets (push) Skipped
CI / python-package (push) Skipped
CI / notify (push) Successful in 5s
New tables on the federation migration branch: followers (pending or accepted, with the Follow activity), per-user blocks, the inbox queue (raw deliveries awaiting verification, deduplicated by activity id), our outgoing activities, and deliveries (per inbox, with retry state). Inbox URLs are capped at 1024 characters (remote actors are validated against it) so the delivery unique index stays within Postgres's btree limit; the remote actor inbox columns shrink to match. 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
52b9f0b27b
commit
d49aa72be1
3 files changed
+272
-6
No files matched your search
@@ -19,6 +19,7 @@ from scrobbler.federation.net import FetchError
|
||||
|
||||
ACTOR_TYPES = {"Person", "Service", "Application", "Group", "Organization"}
|
||||
MAX_AGE = timedelta(hours=24)
|
||||
MAX_URL = 1024
|
||||
|
||||
|
||||
class ActorError(Exception):
|
||||
@@ -34,17 +35,19 @@ def _text(value, limit: int) -> str | None:
|
||||
|
||||
|
||||
def _parse_actor(uri: str, doc: dict) -> dict:
|
||||
if len(uri) > 2048:
|
||||
raise ActorError("actor URI too long")
|
||||
if doc.get("id") != uri:
|
||||
raise ActorError(f"{uri} claims to be {doc.get('id')!r}")
|
||||
if doc.get("type") not in ACTOR_TYPES:
|
||||
raise ActorError(f"{uri} isn't an actor ({doc.get('type')!r})")
|
||||
host = _host(uri)
|
||||
inbox = doc.get("inbox")
|
||||
if not isinstance(inbox, str) or _host(inbox) != host:
|
||||
if not isinstance(inbox, str) or _host(inbox) != host or len(inbox) > MAX_URL:
|
||||
raise ActorError(f"{uri} has no inbox on its own host")
|
||||
endpoints = doc.get("endpoints") if isinstance(doc.get("endpoints"), dict) else {}
|
||||
shared = endpoints.get("sharedInbox")
|
||||
if not isinstance(shared, str) or _host(shared) != host:
|
||||
if not isinstance(shared, str) or _host(shared) != host or len(shared) > MAX_URL:
|
||||
shared = None
|
||||
key = doc.get("publicKey")
|
||||
if isinstance(key, list): # some servers list several
|
||||
|
||||
Reference in new issue
Block a user