kopia lustrzana https://github.com/snarfed/bridgy-fed
ActivityPub.postprocess_as2: always populate images into attachments as objects
hopefully for https://github.com/snarfed/bridgy-fed/issues/1000#issuecomment-2119106644, ATProto images without alt text not showing up in APpull/1067/head
rodzic
976653d5bb
commit
7cf8a77a73
|
@ -685,7 +685,8 @@ def postprocess_as2(activity, orig_obj=None, wrap=True):
|
||||||
imgs = util.get_list(obj_or_activity, 'image')
|
imgs = util.get_list(obj_or_activity, 'image')
|
||||||
if imgs:
|
if imgs:
|
||||||
atts = obj_or_activity['attachment']
|
atts = obj_or_activity['attachment']
|
||||||
atts.extend(img for img in imgs if img not in atts)
|
atts.extend((img if isinstance(img, dict) else {'url': img})
|
||||||
|
for img in imgs if img not in atts)
|
||||||
|
|
||||||
# cc target's author(s), recipients, mentions
|
# cc target's author(s), recipients, mentions
|
||||||
# https://www.w3.org/TR/activitystreams-vocabulary/#audienceTargeting
|
# https://www.w3.org/TR/activitystreams-vocabulary/#audienceTargeting
|
||||||
|
|
|
@ -1950,6 +1950,17 @@ class ActivityPubUtilsTest(TestCase):
|
||||||
'image': [{'url': 'http://r/foo'}, {'url': 'http://r/bar'}],
|
'image': [{'url': 'http://r/foo'}, {'url': 'http://r/bar'}],
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
def test_postprocess_as2_image_bare_string_url(self):
|
||||||
|
self.assert_equals({
|
||||||
|
'id': 'http://localhost/r/xyz',
|
||||||
|
'attachment': [{'url': 'http://r/foo'}],
|
||||||
|
'image': ['http://r/foo'],
|
||||||
|
'to': [as2.PUBLIC_AUDIENCE],
|
||||||
|
}, postprocess_as2({
|
||||||
|
'id': 'xyz',
|
||||||
|
'image': ['http://r/foo'],
|
||||||
|
}))
|
||||||
|
|
||||||
def test_postprocess_as2_note(self):
|
def test_postprocess_as2_note(self):
|
||||||
self.assert_equals({
|
self.assert_equals({
|
||||||
'id': 'http://localhost/r/xyz',
|
'id': 'http://localhost/r/xyz',
|
||||||
|
|
Ładowanie…
Reference in New Issue