Interop with a real GoToSocial server, and the fixes it found (phase 2, step 8)
CI / validate-monitoring (push) Successful in 7s
CI / lint (push) Successful in 10s
CI / test (push) Successful in 2m16s
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 7s
CI / lint (push) Successful in 10s
CI / test (push) Successful in 2m16s
CI / images (push) Skipped
CI / assets (push) Skipped
CI / python-package (push) Skipped
CI / notify (push) Successful in 6s
scripts/interop/run.sh brings up Scrobbler (API, worker, UI behind a throwaway-TLS Caddy) and GoToSocial 0.22.1 on a private .test network, creates a GoToSocial user, drives its sign-in/OAuth screens for a token, and checks: lookup by handle, follow accepted, unfollow, manual approval and approve, remove, block and unblock, and decline. Found and fixed along the way: - Keys whose id is a path serving the actor (GoToSocial's <actor>/main-key) weren't resolved; now all three publishing styles are handled - An Undo of an older Follow arriving after a newer Follow removed the new follower; an Undo now only removes the Follow it names (and Undo referencing a Follow by id is understood) - Rejects embedded the Follow, which some servers (GoToSocial) match by account pair, so a late Reject could cancel a newer request; Rejects now reference the Follow by id - Unblocking didn't tell the other server; it now sends Undo(Block) - Actors publish an (empty) featured collection, which Mastodon and GoToSocial fetch GoToSocial 0.22.1 ignores Reject for already-accepted follows (a TODO in its code, fixed on its main branch); the removal check on its side is skipped until a release has it (GTS_REJECT_ENDS_FOLLOWS=1 enables). 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
ec658a7751
commit
b93cfea5b3
16 files changed
+694
-17
No files matched your search
@@ -105,8 +105,10 @@ def get_actor(uri: str, refresh: bool = False) -> FederationRemoteActor:
|
||||
|
||||
|
||||
def actor_for_key(key_id: str, refresh: bool = False) -> FederationRemoteActor:
|
||||
"""The actor that owns `key_id`: usually `<actor>#main-key`, sometimes a separate
|
||||
key document naming its owner."""
|
||||
"""The actor that owns `key_id`. Servers publish keys three ways:
|
||||
* a fragment of the actor (`<actor>#main-key`, Mastodon);
|
||||
* a URL that serves the actor document itself (`<actor>/main-key`, GoToSocial);
|
||||
* a separate key document naming its `owner`."""
|
||||
cached = db.session.scalar(db.select(FederationRemoteActor).filter_by(public_key_id=key_id))
|
||||
if cached is not None and not refresh:
|
||||
# Any age will do for checking a signature (a failure refreshes once). This also
|
||||
@@ -116,12 +118,24 @@ def actor_for_key(key_id: str, refresh: bool = False) -> FederationRemoteActor:
|
||||
try:
|
||||
return _matching(get_actor(document_url, refresh=True), key_id)
|
||||
except ActorError:
|
||||
# Not an actor: a standalone key document pointing at its owner
|
||||
doc = outbound.signed_get_json(document_url)
|
||||
owner = doc.get("owner")
|
||||
if doc.get("id") != key_id or not isinstance(owner, str) or _host(owner) != _host(key_id):
|
||||
raise
|
||||
return _matching(get_actor(owner, refresh=True), key_id)
|
||||
pass # the key's URL isn't the actor's own URL: find the owner from the document
|
||||
doc = outbound.signed_get_json(document_url)
|
||||
if doc.get("id") == key_id and isinstance(doc.get("owner"), str):
|
||||
owner = doc["owner"] # a standalone key document
|
||||
elif isinstance(doc.get("id"), str) and _key_id_of(doc) == key_id:
|
||||
owner = doc["id"] # the actor document, served at the key's URL
|
||||
else:
|
||||
raise ActorError(f"can't find who owns key {key_id}")
|
||||
if _host(owner) != _host(key_id):
|
||||
raise ActorError(f"key {key_id} claims an owner on another host")
|
||||
return _matching(get_actor(owner, refresh=True), key_id)
|
||||
|
||||
|
||||
def _key_id_of(doc: dict) -> str | None:
|
||||
key = doc.get("publicKey")
|
||||
if isinstance(key, list):
|
||||
key = next((k for k in key if isinstance(k, dict)), None)
|
||||
return key.get("id") if isinstance(key, dict) else None
|
||||
|
||||
|
||||
def _matching(actor: FederationRemoteActor, key_id: str) -> FederationRemoteActor:
|
||||
|
||||
Reference in new issue
Block a user