mirror of
https://codeberg.org/rimu/pyfedi
synced 2025-01-23 19:36:56 -08:00
invalid attachment activitypub
This commit is contained in:
parent
62292cb6d1
commit
3dff7ef2e7
1 changed files with 2 additions and 4 deletions
|
@ -166,7 +166,7 @@ def post_to_activity(post: Post, community: Community):
|
||||||
if post.language is not None:
|
if post.language is not None:
|
||||||
activity_data["object"]["object"]["language"] = {"identifier": post.language}
|
activity_data["object"]["object"]["language"] = {"identifier": post.language}
|
||||||
if post.type == POST_TYPE_LINK and post.url is not None:
|
if post.type == POST_TYPE_LINK and post.url is not None:
|
||||||
activity_data["object"]["object"]["attachment"] = {"href": post.url, "type": "Link"}
|
activity_data["object"]["object"]["attachment"] = [{"href": post.url, "type": "Link"}]
|
||||||
if post.image_id is not None:
|
if post.image_id is not None:
|
||||||
activity_data["object"]["object"]["image"] = {"url": post.image.view_url(), "type": "Image"}
|
activity_data["object"]["object"]["image"] = {"url": post.image.view_url(), "type": "Image"}
|
||||||
if post.image.alt_text:
|
if post.image.alt_text:
|
||||||
|
@ -598,9 +598,7 @@ def post_json_to_model(post_json, user, community) -> Post:
|
||||||
elif 'content' in post_json:
|
elif 'content' in post_json:
|
||||||
post.body_html = allowlist_html(post_json['content'])
|
post.body_html = allowlist_html(post_json['content'])
|
||||||
post.body = html_to_markdown(post.body_html)
|
post.body = html_to_markdown(post.body_html)
|
||||||
if 'attachment' in post_json and \
|
if 'attachment' in post_json and len(post_json['attachment']) > 0 and 'type' in post_json['attachment'][0]:
|
||||||
len(post_json['attachment']) > 0 and \
|
|
||||||
'type' in post_json['attachment'][0]:
|
|
||||||
if post_json['attachment'][0]['type'] == 'Link':
|
if post_json['attachment'][0]['type'] == 'Link':
|
||||||
post.url = post_json['attachment'][0]['href']
|
post.url = post_json['attachment'][0]['href']
|
||||||
if is_image_url(post.url):
|
if is_image_url(post.url):
|
||||||
|
|
Loading…
Add table
Reference in a new issue