Ryan Barrett 2022-11-28 17:25:39 -08:00
rodzic d4af114247
commit 559f02ad1d
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 6BE31FDF4776E9D4
3 zmienionych plików z 18 dodań i 4 usunięć

Wyświetl plik

@ -62,13 +62,15 @@ def inbox(domain=None):
except (TypeError, ValueError, AssertionError):
error(f"Couldn't parse body as JSON", exc_info=True)
logger.info(f'Got: {json_dumps(activity, indent=2)}')
type = activity.get('type')
actor = activity.get('actor')
actor_id = actor.get('id') if isinstance(actor, dict) else actor
logger.info(f'Got {type} activity from {actor_id}: {json_dumps(activity, indent=2)}')
obj = activity.get('object') or {}
if isinstance(obj, str):
obj = {'id': obj}
type = activity.get('type')
if type == 'Accept': # eg in response to a Follow
return '' # noop
if type not in SUPPORTED_TYPES:
@ -106,7 +108,6 @@ def inbox(domain=None):
return 'OK'
# fetch actor if necessary so we have name, profile photo, etc
actor = activity.get('actor')
if actor and isinstance(actor, str):
actor = activity['actor'] = common.get_as2(actor, user=user).json()

Wyświetl plik

@ -529,7 +529,12 @@ def actor(domain, user=None):
if tld in TLD_BLOCKLIST:
error('', status=404)
mf2 = util.fetch_mf2(f'https://{domain}/', gateway=True)
url = f'https://{domain}/'
try:
mf2 = util.fetch_mf2(url, gateway=True)
except ValueError as e:
error(f"Couldn't fetch {url}: {e}")
hcard = mf2util.representative_hcard(mf2, mf2['url'])
logger.info(f'Representative h-card: {json_dumps(hcard, indent=2)}')
if not hcard:

Wyświetl plik

@ -219,6 +219,14 @@ class ActivityPubTest(testutil.TestCase):
got = self.client.get('/foo.json')
self.assertEqual(404, got.status_code)
def test_actor_bad_domain(self, _, mock_get, ___):
# https://console.cloud.google.com/errors/detail/CKGv-b6impW3Jg;time=P30D?project=bridgy-federated
mock_get.side_effect = [
ValueError('Invalid IPv6 URL'),
]
got = self.client.get('/snarfed.org]')
self.assertEqual(400, got.status_code)
def test_inbox_reply_object(self, *mocks):
self._test_inbox_reply(REPLY_OBJECT, REPLY_OBJECT, *mocks)