kopia lustrzana https://github.com/snarfed/bridgy-fed
AP inbox bug fix: handle Like with null object
fixes https://console.cloud.google.com/errors/detail/CIiI9b-nz7-bIA;time=P30D?project=bridgy-federatedpull/655/head
rodzic
eb4d4cc9db
commit
771de9770e
|
@ -526,7 +526,7 @@ class Protocol:
|
|||
# TODO: do we convert stop-following to webmention 410 of original
|
||||
# follow?
|
||||
|
||||
elif obj.type == 'update':
|
||||
elif obj.type in ('update', 'like', 'share'): # require object
|
||||
if not inner_obj_id:
|
||||
error("Couldn't find id of object to update")
|
||||
|
||||
|
|
|
@ -777,6 +777,16 @@ class ActivityPubTest(TestCase):
|
|||
self.assert_user(ActivityPub, 'https://mas.to/actor',
|
||||
obj_as2=LIKE_ACTOR, direct=True)
|
||||
|
||||
def test_inbox_like_no_object_error(self, *_):
|
||||
Fake.fetchable = {'fake:user': {'id': 'fake:user'}}
|
||||
got = self.post('/inbox', json={
|
||||
'id': 'fake:like',
|
||||
'type': 'Like',
|
||||
'actor': 'fake:user',
|
||||
'object': None,
|
||||
})
|
||||
self.assertEqual(400, got.status_code)
|
||||
|
||||
def test_inbox_follow_accept_with_id(self, *mocks):
|
||||
self._test_inbox_follow_accept(FOLLOW_WRAPPED, ACCEPT, 200, *mocks)
|
||||
|
||||
|
|
|
@ -759,6 +759,26 @@ class ProtocolReceiveTest(TestCase):
|
|||
|
||||
self.assertEqual([(like_obj, 'fake:post:target')], Fake.sent)
|
||||
|
||||
def test_like_no_object_error(self):
|
||||
with self.assertRaises(BadRequest):
|
||||
Fake.receive_as1({
|
||||
'id': 'fake:like',
|
||||
'objectType': 'activity',
|
||||
'verb': 'like',
|
||||
'actor': 'fake:user',
|
||||
'object': None,
|
||||
})
|
||||
|
||||
def test_share_no_object_error(self):
|
||||
with self.assertRaises(BadRequest):
|
||||
Fake.receive_as1({
|
||||
'id': 'fake:share',
|
||||
'objectType': 'activity',
|
||||
'verb': 'share',
|
||||
'actor': 'fake:user',
|
||||
'object': None,
|
||||
})
|
||||
|
||||
def test_delete(self):
|
||||
g.user = None # should use activity's actor
|
||||
self.make_followers()
|
||||
|
|
|
@ -1884,10 +1884,7 @@ class WebUtilTest(TestCase):
|
|||
for id in 'user.com', 'http://user.com', 'https://user.com/':
|
||||
self.assertEqual(Web(id='user.com').key, Web.key_for(id))
|
||||
|
||||
with self.assertRaises(ValueError):
|
||||
Web.key_for('')
|
||||
|
||||
for bad in 'foo', 'https://foo/', 'foo bar', 'user.json':
|
||||
for bad in '', 'foo', 'https://foo/', 'foo bar', 'user.json':
|
||||
with self.subTest(bad=bad):
|
||||
self.assertIsNone(Web.key_for(bad))
|
||||
|
||||
|
|
2
web.py
2
web.py
|
@ -247,7 +247,7 @@ class Web(User, Protocol):
|
|||
ValueError
|
||||
"""
|
||||
if not id:
|
||||
raise ValueError()
|
||||
return None
|
||||
|
||||
if util.is_web(id):
|
||||
parsed = urlparse(id)
|
||||
|
|
Ładowanie…
Reference in New Issue