diff --git a/models.py b/models.py index f4acf95..ea7dc9b 100644 --- a/models.py +++ b/models.py @@ -627,7 +627,7 @@ class Object(StringIdModel): ATProto = PROTOCOLS['atproto'] handle = ATProto(id=owner).handle obj = bluesky.to_as1(self.bsky, repo_did=owner, repo_handle=handle, - uri=self.key.id(), pds=ATProto.target_for(self)) + uri=self.key.id(), pds=ATProto.pds_for(self)) elif self.mf2: obj = microformats2.json_to_object(self.mf2, @@ -868,9 +868,6 @@ class Object(StringIdModel): # TODO: optimize! this is called serially in loops, eg in home.html if set(actor.keys()) == {'id'} and self.source_protocol: proto = PROTOCOLS[self.source_protocol] - # STATE: this load gets the DID doc, not the profile object - # should we start using at://[did] as actor/author? or special case - # atproto here? actor_obj = proto.load(actor['id'], remote=False) if actor_obj and actor_obj.as1: actor = actor_obj.as1 diff --git a/tests/test_models.py b/tests/test_models.py index f43dc6f..5f0da36 100644 --- a/tests/test_models.py +++ b/tests/test_models.py @@ -642,6 +642,23 @@ class ObjectTest(TestCase): obj = Object(id='at://did:plc:foo/like/123', bsky=like_bsky) self.assert_equals(like_as1, obj.as1) + def test_as1_from_bsky_image_blob(self): + self.store_object(id='did:web:alice.com', raw={ + **DID_DOC, + 'alsoKnownAs': ['at://alice.com'], + }) + + obj = Object(id='at://did:web:alice.com/app.bsky.actor.profile/self', bsky={ + **ACTOR_PROFILE_BSKY, + 'banner': None, + }) + self.assert_equals({ + **ACTOR_AS, + 'image': [{ + 'url': 'https://some.pds/xrpc/com.atproto.sync.getBlob?did=did:web:alice.com&cid=bafkreim', + }], + }, obj.as1) + def test_as1_from_mf2_uses_url_as_id(self): obj = Object(mf2={ 'properties': {