diff --git a/app/activitypub/util.py b/app/activitypub/util.py index 47e3c42b..1d0138c7 100644 --- a/app/activitypub/util.py +++ b/app/activitypub/util.py @@ -190,8 +190,10 @@ def post_to_page(post: Post): activity_data["attachment"] = [{"href": post.url, "type": "Link"}] if post.image_id is not None: activity_data["image"] = {"url": post.image.view_url(), "type": "Image"} - if post.image.alt_text: - activity_data["image"]['altText'] = post.image.alt_text + if post.type == POST_TYPE_IMAGE: + activity_data['attachment'] = [{'type': 'Image', + 'url': post.image.source_url, + 'name': post.image.alt_text}] if post.type == POST_TYPE_POLL: poll = Poll.query.filter_by(post_id=post.id).first() activity_data['type'] = 'Question' diff --git a/app/community/routes.py b/app/community/routes.py index 3afc5353..46c297c3 100644 --- a/app/community/routes.py +++ b/app/community/routes.py @@ -696,8 +696,9 @@ def federate_post(community, post): # NB image is a dict while attachment is a list of dicts (usually just one dict in the list) page['image'] = {'type': 'Image', 'url': image_url} if post.type == POST_TYPE_IMAGE: - page['attachment'] = [{'type': 'Link', - 'href': post.image.source_url}] # source_url is always a https link, no need for .replace() as done above + page['attachment'] = [{'type': 'Image', + 'url': post.image.source_url, # source_url is always a https link, no need for .replace() as done above + 'name': post.image.alt_text}] if post.type == POST_TYPE_POLL: poll = Poll.query.filter_by(post_id=post.id).first() @@ -801,10 +802,7 @@ def federate_post_to_user_followers(post): elif post.type == POST_TYPE_IMAGE: note['content'] = '

' + post.title + '

' if post.image_id and post.image.source_url: - if post.image.alt_text: - note['attachment'] = [{'type': 'Document', 'url': post.image.source_url, 'name': post.image.alt_text}] - else: - note['attachment'] = [{'type': 'Document', 'url': post.image.source_url}] + note['attachment'] = [{'type': 'Image', 'url': post.image.source_url, 'name': post.image.alt_text}] if post.body_html: note['content'] = note['content'] + '

' + post.body_html + '

' diff --git a/app/post/routes.py b/app/post/routes.py index 79bd5526..ef968e9b 100644 --- a/app/post/routes.py +++ b/app/post/routes.py @@ -1055,8 +1055,9 @@ def federate_post_update(post): # NB image is a dict while attachment is a list of dicts (usually just one dict in the list) page_json['image'] = {'type': 'Image', 'url': image_url} if post.type == POST_TYPE_IMAGE: - page_json['attachment'] = [{'type': 'Link', - 'href': post.image.source_url}] # source_url is always a https link, no need for .replace() as done above + page_json['attachment'] = [{'type': 'Image', + 'url': post.image.source_url, # source_url is always a https link, no need for .replace() as done above + 'name': post.image.alt_text}] if post.type == POST_TYPE_POLL: poll = Poll.query.filter_by(post_id=post.id).first() page_json['type'] = 'Question' @@ -1151,10 +1152,7 @@ def federate_post_edit_to_user_followers(post): elif post.type == POST_TYPE_IMAGE: note['content'] = '

' + post.title + '

' if post.image_id and post.image.source_url: - if post.image.alt_text: - note['attachment'] = [{'type': 'Document', 'url': post.image.source_url, 'name': post.image.alt_text}] - else: - note['attachment'] = [{'type': 'Document', 'url': post.image.source_url}] + note['attachment'] = [{'type': 'Image', 'url': post.image.source_url, 'name': post.image.alt_text}] elif post.type == POST_TYPE_POLL: poll = Poll.query.filter_by(post_id=post.id).first() note['type'] = 'Question'