Ryan Barrett 2024-06-04 12:03:34 -07:00
rodzic 712da61181
commit 918b2f04ee
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 6BE31FDF4776E9D4
2 zmienionych plików z 18 dodań i 4 usunięć

Wyświetl plik

@ -2927,6 +2927,20 @@ class WebUtilTest(TestCase):
mock_get.assert_not_called()
mock_post.assert_not_called()
def test_send_skips_question(self, mock_get, mock_post):
question = {
'type': 'Question',
'id': 'fake:q',
'inReplyTo': 'user.com',
}
for input in (question, {'type': 'Update', 'object': question}):
with self.subTest(input=input):
obj = Object(id='fake:q', source_protocol='fake', as2=input)
self.assertFalse(Web.send(obj, 'https://user.com/'))
mock_get.assert_not_called()
mock_post.assert_not_called()
def test_send_blocklisted(self, mock_get, mock_post):
obj = Object(id='http://mas.to/like#ok', as2={
**test_activitypub.LIKE,

8
web.py
Wyświetl plik

@ -394,10 +394,10 @@ class Web(User, Protocol):
# we only send webmentions for responses. for sending normal posts etc
# to followers, we just update our stored objects (elsewhere) and web
# users consume them via feeds.
verb = obj.as1.get('verb')
if verb in ('accept', 'undo'):
logger.info(f'Skipping sending {verb} (not supported in webmention/mf2) to {url}')
inner_type = as1.get_object(obj.as1).get('objectType') or ''
if (obj.type in ('accept', 'question', 'undo')
or inner_type in ('question',)):
logger.info(f'Skipping sending {obj.type} {inner_type} (not supported in webmention/mf2) to {url}')
return False
targets = as1.targets(obj.as1)