Skip to content

Commit

Permalink
Protocol.check_supported: block DMs (for now)
Browse files Browse the repository at this point in the history
  • Loading branch information
snarfed committed Aug 1, 2024
1 parent 2257088 commit d769d03
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
11 changes: 7 additions & 4 deletions protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -1576,12 +1576,15 @@ def check_supported(cls, obj):
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():
Expand Down
8 changes: 8 additions & 0 deletions tests/test_protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -720,6 +720,14 @@ def test_check_supported(self):
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):

Expand Down

0 comments on commit d769d03

Please sign in to comment.