kopia lustrzana https://github.com/snarfed/bridgy-fed
Activity.target_for: fix infinite loop when author is object id
fixes #603 and https://console.cloud.google.com/errors/detail/CLPmoOqegtfm0AE;time=P30D?project=bridgy-federatedpull/602/head
rodzic
2f308b43e2
commit
8850e27374
|
@ -133,7 +133,9 @@ class ActivityPub(User, Protocol):
|
|||
for field in 'actor', 'author', 'attributedTo':
|
||||
inner_obj = as1.get_object(obj.as1, field)
|
||||
inner_id = inner_obj.get('id') or as1.get_url(inner_obj)
|
||||
if not inner_id:
|
||||
if (not inner_id
|
||||
or inner_id == obj.as1.get('id')
|
||||
or (obj.key and inner_id == obj.key.id())):
|
||||
continue
|
||||
|
||||
# TODO: need a "soft" kwarg for load to suppress errors?
|
||||
|
|
|
@ -1932,6 +1932,14 @@ class ActivityPubUtilsTest(TestCase):
|
|||
self.assertEqual('http://mas.to/inbox', ActivityPub.target_for(obj))
|
||||
mock_get.assert_has_calls([self.as2_req('http://the/author')])
|
||||
|
||||
@patch('requests.get')
|
||||
def test_target_for_author_is_object_id(self, mock_get):
|
||||
obj = self.store_object(id='http://the/author', our_as1={
|
||||
'author': 'http://the/author',
|
||||
})
|
||||
# test is that we short circuit out instead of infinite recursion
|
||||
self.assertIsNone(ActivityPub.target_for(obj))
|
||||
|
||||
@patch('requests.post')
|
||||
def test_send_blocklisted(self, mock_post):
|
||||
self.assertFalse(ActivityPub.send(Object(as2=NOTE),
|
||||
|
|
Ładowanie…
Reference in New Issue