kopia lustrzana https://github.com/snarfed/bridgy-fed
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 bridgedpull/1158/head
rodzic
7df8990ed2
commit
a735396864
|
@ -719,6 +719,7 @@ class Protocol:
|
||||||
translate(tag, 'url', translate_user_id)
|
translate(tag, 'url', translate_user_id)
|
||||||
for att in as1.get_objects(o, 'attachments'):
|
for att in as1.get_objects(o, 'attachments'):
|
||||||
translate(att, 'id', translate_object_id)
|
translate(att, 'id', translate_object_id)
|
||||||
|
translate(att, 'url', translate_object_id)
|
||||||
|
|
||||||
outer_obj = util.trim_nulls(outer_obj)
|
outer_obj = util.trim_nulls(outer_obj)
|
||||||
if outer_obj.get('object', {}).keys() == {'id'}:
|
if outer_obj.get('object', {}).keys() == {'id'}:
|
||||||
|
|
|
@ -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):
|
def test_convert_actor_from_atproto_doesnt_add_self_label(self):
|
||||||
self.assertEqual({
|
self.assertEqual({
|
||||||
'$type': 'app.bsky.actor.profile',
|
'$type': 'app.bsky.actor.profile',
|
||||||
|
|
|
@ -536,7 +536,7 @@ class ProtocolTest(TestCase):
|
||||||
'objectType': 'note',
|
'objectType': 'note',
|
||||||
'attachments': [
|
'attachments': [
|
||||||
{'id': 'other:o:fa:fake:123'},
|
{'id': 'other:o:fa:fake:123'},
|
||||||
{'url': 'fake:456'},
|
{'url': 'other:o:fa:fake:456'},
|
||||||
],
|
],
|
||||||
'tags': [
|
'tags': [
|
||||||
{'objectType': 'mention', 'url': 'other:u:fake:alice'},
|
{'objectType': 'mention', 'url': 'other:u:fake:alice'},
|
||||||
|
@ -568,6 +568,10 @@ class ProtocolTest(TestCase):
|
||||||
'id': 'other:o:fa:fake:reply',
|
'id': 'other:o:fa:fake:reply',
|
||||||
'inReplyTo': 'other:post',
|
'inReplyTo': 'other:post',
|
||||||
},
|
},
|
||||||
|
'attachments': [{
|
||||||
|
'objectType': 'note',
|
||||||
|
'url': 'other:post',
|
||||||
|
}],
|
||||||
}, OtherFake.translate_ids({
|
}, OtherFake.translate_ids({
|
||||||
'objectType': 'activity',
|
'objectType': 'activity',
|
||||||
'verb': 'post',
|
'verb': 'post',
|
||||||
|
@ -576,6 +580,10 @@ class ProtocolTest(TestCase):
|
||||||
'id': 'fake:reply',
|
'id': 'fake:reply',
|
||||||
'inReplyTo': 'fake:post',
|
'inReplyTo': 'fake:post',
|
||||||
},
|
},
|
||||||
|
'attachments': [{
|
||||||
|
'objectType': 'note',
|
||||||
|
'url': 'fake:post',
|
||||||
|
}],
|
||||||
}))
|
}))
|
||||||
|
|
||||||
def test_convert_object_is_from_user_adds_source_links(self):
|
def test_convert_object_is_from_user_adds_source_links(self):
|
||||||
|
|
Ładowanie…
Reference in New Issue