diff --git a/atproto.py b/atproto.py index 1f32675..035de77 100644 --- a/atproto.py +++ b/atproto.py @@ -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(): diff --git a/tests/test_atproto.py b/tests/test_atproto.py index 7dc7355..02e1f04 100644 --- a/tests/test_atproto.py +++ b/tests/test_atproto.py @@ -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'))