mirror of
https://github.com/jointakahe/takahe.git
synced 2025-02-22 18:26:17 +00:00
Correctly handle response.raise_for_status() and guard search from bubbling parse errors (#322)
This commit is contained in:
parent
0250f2800b
commit
75c17c0766
2 changed files with 12 additions and 9 deletions
|
@ -41,15 +41,18 @@ class SearchService:
|
|||
username__iexact=username,
|
||||
)
|
||||
except Identity.DoesNotExist:
|
||||
identity = None
|
||||
if self.identity is not None:
|
||||
# Allow authenticated users to fetch remote
|
||||
identity = Identity.by_username_and_domain(
|
||||
username, domain_instance or domain, fetch=True
|
||||
)
|
||||
if identity and identity.state == IdentityStates.outdated:
|
||||
async_to_sync(identity.fetch_actor)()
|
||||
else:
|
||||
identity = None
|
||||
try:
|
||||
# Allow authenticated users to fetch remote
|
||||
identity = Identity.by_username_and_domain(
|
||||
username, domain_instance or domain, fetch=True
|
||||
)
|
||||
if identity and identity.state == IdentityStates.outdated:
|
||||
async_to_sync(identity.fetch_actor)()
|
||||
except ValueError:
|
||||
pass
|
||||
|
||||
if identity:
|
||||
results.add(identity)
|
||||
|
||||
|
|
|
@ -640,7 +640,7 @@ class Identity(StatorModel):
|
|||
headers={"Accept": "application/json"},
|
||||
)
|
||||
response.raise_for_status()
|
||||
except httpx.RequestError as ex:
|
||||
except httpx.HTTPError as ex:
|
||||
response = getattr(ex, "response", None)
|
||||
if (
|
||||
response
|
||||
|
|
Loading…
Reference in a new issue