diff options
Diffstat (limited to 'users/models')
-rw-r--r-- | users/models/follow.py | 40 | ||||
-rw-r--r-- | users/models/identity.py | 4 |
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. |