From 77643a4fe144cb908a372a2ceb99f36634457ca5 Mon Sep 17 00:00:00 2001 From: Andrew Godwin Date: Sun, 20 Nov 2022 12:24:03 -0700 Subject: Add more error handling --- users/models/identity.py | 4 ++-- users/models/inbox_message.py | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) (limited to 'users') diff --git a/users/models/identity.py b/users/models/identity.py index 452bde7..a78a451 100644 --- a/users/models/identity.py +++ b/users/models/identity.py @@ -277,7 +277,7 @@ class Identity(StatorModel): headers={"Accept": "application/json"}, follow_redirects=True, ) - except (httpx.ReadTimeout, httpx.ReadError, httpx.RemoteProtocolError): + except httpx.RequestError: return None, None if response.status_code >= 400: return None, None @@ -306,7 +306,7 @@ class Identity(StatorModel): headers={"Accept": "application/json"}, follow_redirects=True, ) - except (httpx.ReadTimeout, httpx.ReadError, httpx.RemoteProtocolError): + except httpx.RequestError: return False if response.status_code >= 400: return False diff --git a/users/models/inbox_message.py b/users/models/inbox_message.py index ee23ae6..fc81d71 100644 --- a/users/models/inbox_message.py +++ b/users/models/inbox_message.py @@ -65,6 +65,9 @@ class InboxMessageStates(StateGraph): f"Cannot handle activity of type undo.{unknown}" ) case "delete": + # If there is no object type, it's probably a profile + if not isinstance(instance.message["object"], dict): + raise ValueError("Cannot handle activity of type delete") match instance.message_object_type: case "tombstone": await sync_to_async(Post.handle_delete_ap)(instance.message) -- cgit v1.2.3