diff options
author | Andrew Godwin | 2022-11-20 11:37:26 -0700 |
---|---|---|
committer | Andrew Godwin | 2022-11-20 11:37:26 -0700 |
commit | 7a4f9cf29327803597cd39a46df159df4fbabe6c (patch) | |
tree | dea0896006852cbc291d3c00068e537927a1a985 /users/models | |
parent | ef910c53b7537cff385510c446bb7e2498875194 (diff) | |
download | takahe-7a4f9cf29327803597cd39a46df159df4fbabe6c.tar.gz takahe-7a4f9cf29327803597cd39a46df159df4fbabe6c.tar.bz2 takahe-7a4f9cf29327803597cd39a46df159df4fbabe6c.zip |
Add error catching on actor fetch
Diffstat (limited to 'users/models')
-rw-r--r-- | users/models/identity.py | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/users/models/identity.py b/users/models/identity.py index 53b6f80..5056ce0 100644 --- a/users/models/identity.py +++ b/users/models/identity.py @@ -297,11 +297,14 @@ class Identity(StatorModel): if self.local: raise ValueError("Cannot fetch local identities") async with httpx.AsyncClient() as client: - response = await client.get( - self.actor_uri, - headers={"Accept": "application/json"}, - follow_redirects=True, - ) + try: + response = await client.get( + self.actor_uri, + headers={"Accept": "application/json"}, + follow_redirects=True, + ) + except (httpx.ReadTimeout, httpx.ReadError): + return False if response.status_code >= 400: return False document = canonicalise(response.json(), include_security=True) |