From d769d03a4f8e784e5f7731f655d10da6c14b954c Mon Sep 17 00:00:00 2001 From: Ryan Barrett Date: Wed, 31 Jul 2024 23:12:37 -0700 Subject: [PATCH] Protocol.check_supported: block DMs (for now) --- protocol.py | 11 +++++++---- tests/test_protocol.py | 8 ++++++++ 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/protocol.py b/protocol.py index 3d4ba1c..76ddd4b 100644 --- a/protocol.py +++ b/protocol.py @@ -1576,12 +1576,15 @@ class Protocol: return inner_type = as1.object_type(as1.get_object(obj.as1)) or '' - if (obj.type not in cls.SUPPORTED_AS1_TYPES or - (obj.type in as1.CRUD_VERBS - and inner_type - and inner_type not in cls.SUPPORTED_AS1_TYPES)): + if (obj.type not in cls.SUPPORTED_AS1_TYPES + or (obj.type in as1.CRUD_VERBS + and inner_type + and inner_type not in cls.SUPPORTED_AS1_TYPES)): error(f"Bridgy Fed for {cls.LABEL} doesn't support {obj.type} {inner_type} yet", status=204) + if as1.is_dm(obj.as1): + error(f"Bridgy Fed doesn't support DMs", status=204) + @cloud_tasks_only def receive_task(): diff --git a/tests/test_protocol.py b/tests/test_protocol.py index 4c7ecd3..509265d 100644 --- a/tests/test_protocol.py +++ b/tests/test_protocol.py @@ -720,6 +720,14 @@ class ProtocolTest(TestCase): with self.assertRaises(NoContent): Fake.check_supported(Object(our_as1=obj)) + # DM + with self.assertRaises(NoContent): + Fake.check_supported(Object(our_as1={ + 'objectType': 'note', + 'actor': 'did:alice', + 'to': ['did:bob'], + 'content': 'hello world', + })) class ProtocolReceiveTest(TestCase):