kopia lustrzana https://github.com/snarfed/bridgy-fed
rodzic
b7bebb4075
commit
72024f90b1
|
@ -108,7 +108,7 @@ class ActivityPub(User, Protocol):
|
|||
resp = signed_get(url, headers=headers, gateway=True)
|
||||
if not resp.content:
|
||||
_error('empty response')
|
||||
elif common.content_type(resp) == as2.CONTENT_TYPE:
|
||||
elif common.content_type(resp) in as2.CONTENT_TYPES:
|
||||
try:
|
||||
return resp.json()
|
||||
except requests.JSONDecodeError:
|
||||
|
|
|
@ -153,7 +153,8 @@ class FollowCallback(indieauth.Callback):
|
|||
|
||||
as2_url = None
|
||||
for link in webfinger.get('links', []):
|
||||
if link.get('rel') == 'self' and link.get('type') == as2.CONTENT_TYPE:
|
||||
type = link.get('type', '').split(';')[0]
|
||||
if link.get('rel') == 'self' and type in as2.CONTENT_TYPES:
|
||||
as2_url = link.get('href')
|
||||
|
||||
if not as2_url:
|
||||
|
|
|
@ -1369,6 +1369,19 @@ class ActivityPubUtilsTest(TestCase):
|
|||
self.as2_req('http://orig'),
|
||||
))
|
||||
|
||||
@patch('requests.get')
|
||||
def test_fetch_direct_ld_content_type(self, mock_get):
|
||||
mock_get.return_value = requests_response(AS2_OBJ, headers={
|
||||
'Content-Type': 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"',
|
||||
})
|
||||
obj = Object(id='http://orig')
|
||||
ActivityPub.fetch(obj)
|
||||
self.assertEqual(AS2_OBJ, obj.as2)
|
||||
|
||||
mock_get.assert_has_calls((
|
||||
self.as2_req('http://orig'),
|
||||
))
|
||||
|
||||
@patch('requests.get')
|
||||
def test_fetch_via_html(self, mock_get):
|
||||
mock_get.side_effect = [HTML_WITH_AS2, AS2]
|
||||
|
|
Ładowanie…
Reference in New Issue