bug fix for pds_for change in e86763f: don't use Object.as1 since that infinite loops

pull/923/head
Ryan Barrett 2024-03-14 21:16:09 -07:00
rodzic e86763f654
commit 048cd17ba5
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 6BE31FDF4776E9D4
2 zmienionych plików z 11 dodań i 1 usunięć

Wyświetl plik

@ -178,7 +178,9 @@ class ATProto(User, Protocol):
# None here? or do we need this path to return BF's URL so that we
# then create the DID for non-ATP users on demand?
if obj.as1:
# don't use Object.as1 if bsky is set, since that conversion calls
# pds_for, which would infinite loop
if not obj.bsky and obj.as1:
if owner := as1.get_owner(obj.as1):
if user_key := Protocol.key_for(owner):
if user := user_key.get():

Wyświetl plik

@ -156,6 +156,14 @@ class ATProtoTest(TestCase):
got = ATProto.pds_for(Object(id='at://did:plc:user/co.ll/123'))
self.assertEqual('https://some.pds', got)
def test_pds_for_bsky_record_stored_did(self):
# check that we don't use Object.as1, which would cause an infinite loop
self.assertIsNone(ATProto.pds_for(Object(id='at://did:bob/coll/post', bsky={
'$type': 'app.bsky.feed.post',
'uri': 'at://did:bob/coll/post',
'cid': 'my sidd',
})))
@patch('requests.get', return_value=requests_response(DID_DOC))
def test_pds_for_fetch_did(self, mock_get):
got = ATProto.pds_for(Object(id='at://did:plc:user/co.ll/123'))