kopia lustrzana https://github.com/snarfed/bridgy-fed
common.postprocess_as2 bug fix, handle multiply valued image field
rodzic
0d0a4ed642
commit
46736df21b
|
@ -417,9 +417,9 @@ def postprocess_as2(activity, user=None, target=None, create=True):
|
||||||
# copy image(s) into attachment(s). may be Mastodon-specific.
|
# copy image(s) into attachment(s). may be Mastodon-specific.
|
||||||
# https://github.com/snarfed/bridgy-fed/issues/33#issuecomment-440965618
|
# https://github.com/snarfed/bridgy-fed/issues/33#issuecomment-440965618
|
||||||
obj_or_activity = obj if isinstance(obj, dict) else activity
|
obj_or_activity = obj if isinstance(obj, dict) else activity
|
||||||
img = obj_or_activity.get('image')
|
img = util.get_list(obj_or_activity, 'image')
|
||||||
if img:
|
if img:
|
||||||
obj_or_activity.setdefault('attachment', []).append(img)
|
obj_or_activity.setdefault('attachment', []).extend(img)
|
||||||
|
|
||||||
# cc target's author(s) and recipients
|
# cc target's author(s) and recipients
|
||||||
# https://www.w3.org/TR/activitystreams-vocabulary/#audienceTargeting
|
# https://www.w3.org/TR/activitystreams-vocabulary/#audienceTargeting
|
||||||
|
|
|
@ -110,6 +110,18 @@ class CommonTest(testutil.TestCase):
|
||||||
'url': ['foo', 'bar'],
|
'url': ['foo', 'bar'],
|
||||||
}, user=User(id='foo.com')))
|
}, user=User(id='foo.com')))
|
||||||
|
|
||||||
|
def test_postprocess_as2_multiple_image(self):
|
||||||
|
with app.test_request_context('/'):
|
||||||
|
self.assert_equals({
|
||||||
|
'id': 'http://localhost/r/xyz',
|
||||||
|
'attachment': [{'url': 'http://r/foo'}, {'url': 'http://r/bar'}],
|
||||||
|
'image': [{'url': 'http://r/foo'}, {'url': 'http://r/bar'}],
|
||||||
|
'to': [as2.PUBLIC_AUDIENCE],
|
||||||
|
}, common.postprocess_as2({
|
||||||
|
'id': 'xyz',
|
||||||
|
'image': [{'url': 'http://r/foo'}, {'url': 'http://r/bar'}],
|
||||||
|
}, user=User(id='foo.com')))
|
||||||
|
|
||||||
def test_postprocess_as2_actor_attributedTo(self):
|
def test_postprocess_as2_actor_attributedTo(self):
|
||||||
with app.test_request_context('/'):
|
with app.test_request_context('/'):
|
||||||
self.assert_equals({
|
self.assert_equals({
|
||||||
|
|
|
@ -231,9 +231,9 @@ class Webmention(View):
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
# not actually an error
|
# not actually an error
|
||||||
msg = ("Updating profile on followers' instances"
|
msg = ("Updating profile on followers' instances..."
|
||||||
if self.source_url.strip('/') == f'https://{self.source_domain}'
|
if self.source_url.strip('/') == f'https://{self.source_domain}'
|
||||||
else 'Delivering to followers')
|
else 'Delivering to followers...')
|
||||||
error(msg, status=202)
|
error(msg, status=202)
|
||||||
|
|
||||||
inboxes = set()
|
inboxes = set()
|
||||||
|
|
Ładowanie…
Reference in New Issue