kopia lustrzana https://github.com/snarfed/bridgy-fed
Protocol.translate_ids: fix user-visible quote post URL
broken by a735396
, for #1154 and #461
pull/1158/head
rodzic
308501236e
commit
ac2df747a6
|
@ -723,7 +723,10 @@ 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)
|
url = att.get('url')
|
||||||
|
if url and not att.get('id'):
|
||||||
|
from_cls = Protocol.for_id(url)
|
||||||
|
att['id'] = translate_object_id(from_=from_cls, to=to_cls, id=url)
|
||||||
|
|
||||||
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'}:
|
||||||
|
|
|
@ -2557,6 +2557,35 @@ class ActivityPubUtilsTest(TestCase):
|
||||||
'object': ACTOR,
|
'object': ACTOR,
|
||||||
}, ActivityPub.convert(obj))
|
}, ActivityPub.convert(obj))
|
||||||
|
|
||||||
|
def test_convert_quote_post(self):
|
||||||
|
obj = Object(id='at://did:alice/app.bsky.feed.post/123', bsky={
|
||||||
|
'$type': 'app.bsky.feed.post',
|
||||||
|
'text': 'foo bar',
|
||||||
|
'embed': {
|
||||||
|
'$type': 'app.bsky.embed.record',
|
||||||
|
'record': {
|
||||||
|
'cid': 'bafyreih...',
|
||||||
|
'uri': 'at://did:bob/app.bsky.feed.post/456'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
self.assert_equals({
|
||||||
|
'type': 'Note',
|
||||||
|
'id': 'https://bsky.brid.gy/convert/ap/at://did:alice/app.bsky.feed.post/123',
|
||||||
|
'url': 'http://localhost/r/https://bsky.app/profile/did:alice/post/123',
|
||||||
|
'content': '<p>foo bar<br><br>RE: <a href="https://bsky.app/profile/did:bob/post/456">https://bsky.app/profile/did:bob/post/456</a></p>',
|
||||||
|
'attributedTo': 'did:alice',
|
||||||
|
'_misskey_quote': 'https://bsky.brid.gy/convert/ap/at://did:bob/app.bsky.feed.post/456',
|
||||||
|
'quoteUrl': 'https://bsky.brid.gy/convert/ap/at://did:bob/app.bsky.feed.post/456',
|
||||||
|
'tag': [{
|
||||||
|
'type': 'Link',
|
||||||
|
'mediaType': as2.CONTENT_TYPE_LD_PROFILE,
|
||||||
|
'href': 'https://bsky.brid.gy/convert/ap/at://did:bob/app.bsky.feed.post/456',
|
||||||
|
'name': 'RE: https://bsky.app/profile/did:bob/post/456',
|
||||||
|
}],
|
||||||
|
}, ActivityPub.convert(obj), ignore=['contentMap', 'content_is_html', 'to'])
|
||||||
|
|
||||||
def test_postprocess_as2_idempotent(self):
|
def test_postprocess_as2_idempotent(self):
|
||||||
for obj in (ACTOR, REPLY_OBJECT, REPLY_OBJECT_WRAPPED, REPLY,
|
for obj in (ACTOR, REPLY_OBJECT, REPLY_OBJECT_WRAPPED, REPLY,
|
||||||
NOTE_OBJECT, NOTE, MENTION_OBJECT, MENTION, LIKE,
|
NOTE_OBJECT, NOTE, MENTION_OBJECT, MENTION, LIKE,
|
||||||
|
|
|
@ -536,7 +536,8 @@ class ProtocolTest(TestCase):
|
||||||
'objectType': 'note',
|
'objectType': 'note',
|
||||||
'attachments': [
|
'attachments': [
|
||||||
{'id': 'other:o:fa:fake:123'},
|
{'id': 'other:o:fa:fake:123'},
|
||||||
{'url': 'other:o:fa:fake:456'},
|
{'id': 'other:o:fa:fake:456',
|
||||||
|
'url': 'fake:456'},
|
||||||
],
|
],
|
||||||
'tags': [
|
'tags': [
|
||||||
{'objectType': 'mention', 'url': 'other:u:fake:alice'},
|
{'objectType': 'mention', 'url': 'other:u:fake:alice'},
|
||||||
|
@ -570,7 +571,8 @@ class ProtocolTest(TestCase):
|
||||||
},
|
},
|
||||||
'attachments': [{
|
'attachments': [{
|
||||||
'objectType': 'note',
|
'objectType': 'note',
|
||||||
'url': 'other:post',
|
'id': 'other:post',
|
||||||
|
'url': 'fake:post',
|
||||||
}],
|
}],
|
||||||
}, OtherFake.translate_ids({
|
}, OtherFake.translate_ids({
|
||||||
'objectType': 'activity',
|
'objectType': 'activity',
|
||||||
|
|
Ładowanie…
Reference in New Issue