Protocol.translate_ids: add attachment.url

for https://github.com/snarfed/bridgy-fed/issues/461 , fixes AP => ATProto quote post of AP original post that was bridged
pull/1158/head
Ryan Barrett 2024-06-25 12:27:24 -07:00
rodzic 7df8990ed2
commit a735396864
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 6BE31FDF4776E9D4
3 zmienionych plików z 38 dodań i 1 usunięć

Wyświetl plik

@ -719,6 +719,7 @@ class Protocol:
translate(tag, 'url', translate_user_id)
for att in as1.get_objects(o, 'attachments'):
translate(att, 'id', translate_object_id)
translate(att, 'url', translate_object_id)
outer_obj = util.trim_nulls(outer_obj)
if outer_obj.get('object', {}).keys() == {'id'}:

Wyświetl plik

@ -698,6 +698,34 @@ class ATProtoTest(TestCase):
}],
})))
def test_convert_quote_post_translate_attachment_url_with_copy_id(self):
self.make_user_and_repo()
self.store_object(id='fake:orig-post', copies=[
Target(protocol='atproto', uri='at://did:plc:user/coll/tid'),
])
self.repo.apply_writes([Write(action=Action.CREATE, collection='coll',
rkey='tid', record=NOTE_BSKY)])
self.assertEqual({
'$type': 'app.bsky.feed.post',
'text': '',
'createdAt': '2022-01-02T03:04:05.000Z',
'embed': {
'$type': 'app.bsky.embed.record',
'record': {
'uri': 'at://did:plc:user/coll/tid',
'cid': 'bafyreiccskuaccxa6zbaf7jeaiwyzg3pqtj3rg5qra653f5cmqilvgvejy',
},
},
}, ATProto.convert(Object(our_as1={
'objectType': 'note',
'attachments': [{
'objectType': 'note',
'url': 'fake:orig-post',
}],
})))
def test_convert_actor_from_atproto_doesnt_add_self_label(self):
self.assertEqual({
'$type': 'app.bsky.actor.profile',

Wyświetl plik

@ -536,7 +536,7 @@ class ProtocolTest(TestCase):
'objectType': 'note',
'attachments': [
{'id': 'other:o:fa:fake:123'},
{'url': 'fake:456'},
{'url': 'other:o:fa:fake:456'},
],
'tags': [
{'objectType': 'mention', 'url': 'other:u:fake:alice'},
@ -568,6 +568,10 @@ class ProtocolTest(TestCase):
'id': 'other:o:fa:fake:reply',
'inReplyTo': 'other:post',
},
'attachments': [{
'objectType': 'note',
'url': 'other:post',
}],
}, OtherFake.translate_ids({
'objectType': 'activity',
'verb': 'post',
@ -576,6 +580,10 @@ class ProtocolTest(TestCase):
'id': 'fake:reply',
'inReplyTo': 'fake:post',
},
'attachments': [{
'objectType': 'note',
'url': 'fake:post',
}],
}))
def test_convert_object_is_from_user_adds_source_links(self):