From 933f6660d5c257e81a58da2ecb5725a3670bff56 Mon Sep 17 00:00:00 2001 From: Andrew Godwin Date: Fri, 7 Jul 2023 16:39:02 -0600 Subject: [PATCH] Catch all the subtypes too --- users/models/inbox_message.py | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/users/models/inbox_message.py b/users/models/inbox_message.py index d8b6e61..9dba3db 100644 --- a/users/models/inbox_message.py +++ b/users/models/inbox_message.py @@ -69,9 +69,7 @@ class InboxMessageStates(StateGraph): # It's a string object, but these will only be for Follows Follow.handle_accept_ap(instance.message) case unknown: - raise ValueError( - f"Cannot handle activity of type accept.{unknown}" - ) + return cls.errored case "reject": match instance.message_object_type: case "follow": @@ -80,9 +78,7 @@ class InboxMessageStates(StateGraph): # It's a string object, but these will only be for Follows Follow.handle_reject_ap(instance.message) case unknown: - raise ValueError( - f"Cannot handle activity of type reject.{unknown}" - ) + return cls.errored case "undo": match instance.message_object_type: case "follow": @@ -97,9 +93,7 @@ class InboxMessageStates(StateGraph): # We're ignoring emoji reactions for now pass case unknown: - raise ValueError( - f"Cannot handle activity of type undo.{unknown}" - ) + return cls.errored case "delete": # If there is no object type, we need to see if it's a profile or a post if not isinstance(instance.message["object"], dict): @@ -121,9 +115,7 @@ class InboxMessageStates(StateGraph): case "note": Post.handle_delete_ap(instance.message) case unknown: - raise ValueError( - f"Cannot handle activity of type delete.{unknown}" - ) + return cls.errored case "add": PostInteraction.handle_add_ap(instance.message) case "remove": @@ -150,9 +142,7 @@ class InboxMessageStates(StateGraph): instance.message["object"] ) case unknown: - raise ValueError( - f"Cannot handle activity of type __internal__.{unknown}" - ) + return cls.errored case unknown: return cls.errored return cls.processed