Object.as1 from bsky: bug fix for PDS in getBlob image URLs

pull/923/head
Ryan Barrett 2024-03-14 20:26:46 -07:00
rodzic 878bbde328
commit e86763f654
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 6BE31FDF4776E9D4
2 zmienionych plików z 18 dodań i 4 usunięć

Wyświetl plik

@ -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

Wyświetl plik

@ -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': {