summaryrefslogtreecommitdiffstats
path: root/users
diff options
context:
space:
mode:
authorAndrew Godwin2022-12-17 12:29:48 -0700
committerAndrew Godwin2022-12-17 12:29:48 -0700
commit24a4fbe1f820e6ce13a969f39dd7676894987532 (patch)
treeb88da273407e997e07b519375b1a9e0e6262c663 /users
parent1f28361fd9fe7f73b966f5b1c6e36248ce8114b4 (diff)
downloadtakahe-24a4fbe1f820e6ce13a969f39dd7676894987532.tar.gz
takahe-24a4fbe1f820e6ce13a969f39dd7676894987532.tar.bz2
takahe-24a4fbe1f820e6ce13a969f39dd7676894987532.zip
Catch all possible request errors
Diffstat (limited to 'users')
-rw-r--r--users/models/follow.py40
-rw-r--r--users/models/identity.py4
2 files changed, 27 insertions, 17 deletions
diff --git a/users/models/follow.py b/users/models/follow.py
index 5f0d6ab..e96e988 100644
--- a/users/models/follow.py
+++ b/users/models/follow.py
@@ -1,5 +1,6 @@
from typing import Optional
+import httpx
from django.db import models, transaction
from core.ld import canonicalise
@@ -37,11 +38,14 @@ class FollowStates(StateGraph):
if not follow.source.local:
return cls.remote_requested
# Sign it and send it
- await follow.source.signed_request(
- method="post",
- uri=follow.target.inbox_uri,
- body=canonicalise(follow.to_ap()),
- )
+ try:
+ await follow.source.signed_request(
+ method="post",
+ uri=follow.target.inbox_uri,
+ body=canonicalise(follow.to_ap()),
+ )
+ except httpx.RequestError:
+ return
return cls.local_requested
@classmethod
@@ -56,11 +60,14 @@ class FollowStates(StateGraph):
source server.
"""
follow = await instance.afetch_full()
- await follow.target.signed_request(
- method="post",
- uri=follow.source.inbox_uri,
- body=canonicalise(follow.to_accept_ap()),
- )
+ try:
+ await follow.target.signed_request(
+ method="post",
+ uri=follow.source.inbox_uri,
+ body=canonicalise(follow.to_accept_ap()),
+ )
+ except httpx.RequestError:
+ return
return cls.accepted
@classmethod
@@ -69,11 +76,14 @@ class FollowStates(StateGraph):
Delivers the Undo object to the target server
"""
follow = await instance.afetch_full()
- await follow.source.signed_request(
- method="post",
- uri=follow.target.inbox_uri,
- body=canonicalise(follow.to_undo_ap()),
- )
+ try:
+ await follow.source.signed_request(
+ method="post",
+ uri=follow.target.inbox_uri,
+ body=canonicalise(follow.to_undo_ap()),
+ )
+ except httpx.RequestError:
+ return
return cls.undone_remotely
diff --git a/users/models/identity.py b/users/models/identity.py
index 0ea590e..7c3fa35 100644
--- a/users/models/identity.py
+++ b/users/models/identity.py
@@ -402,7 +402,7 @@ class Identity(StatorModel):
response = await client.get(
f"https://{domain}/.well-known/webfinger?resource=acct:{handle}",
)
- except (httpx.RequestError, httpx.ConnectError):
+ except httpx.RequestError:
return None, None
if response.status_code in [404, 410]:
return None, None
@@ -438,7 +438,7 @@ class Identity(StatorModel):
method="get",
uri=self.actor_uri,
)
- except (httpx.ConnectError, httpx.RequestError):
+ except httpx.RequestError:
return False
if response.status_code == 410:
# Their account got deleted, so let's do the same.