Protocol.check_supported: block DMs (for now)

pull/1225/head
Ryan Barrett 2024-07-31 23:12:37 -07:00
rodzic 22570881b7
commit d769d03a4f
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 6BE31FDF4776E9D4
2 zmienionych plików z 15 dodań i 4 usunięć

Wyświetl plik

@ -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():

Wyświetl plik

@ -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):