mirror of
https://git.sr.ht/~tsileo/microblog.pub
synced 2024-12-22 13:14:28 +00:00
Tweak key fetching
This commit is contained in:
parent
fe88481431
commit
d16628195d
1 changed files with 7 additions and 1 deletions
|
@ -93,7 +93,13 @@ async def _get_public_key(db_session: AsyncSession, key_id: str) -> Key:
|
|||
|
||||
# Without signing the request as if it's the first contact, the 2 servers
|
||||
# might race to fetch each other key
|
||||
actor = await ap.fetch(key_id, disable_httpsig=True)
|
||||
try:
|
||||
actor = await ap.fetch(key_id, disable_httpsig=True)
|
||||
except httpx.HTTPStatusError as http_err:
|
||||
if http_err.response.status_code in [401, 403]:
|
||||
actor = await ap.fetch(key_id, disable_httpsig=False)
|
||||
else:
|
||||
raise
|
||||
if actor["type"] == "Key":
|
||||
# The Key is not embedded in the Person
|
||||
k = Key(actor["owner"], actor["id"])
|
||||
|
|
Loading…
Reference in a new issue