From 5e422131ad8255114e5c236dd592492f4e53d4aa Mon Sep 17 00:00:00 2001 From: freamon Date: Sun, 17 Nov 2024 22:14:39 +0000 Subject: [PATCH] Prefer image in attachment for image posts #350 --- app/activitypub/util.py | 9 +++------ app/models.py | 5 +---- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/app/activitypub/util.py b/app/activitypub/util.py index ed39fddd..f0811f7a 100644 --- a/app/activitypub/util.py +++ b/app/activitypub/util.py @@ -917,12 +917,9 @@ def post_json_to_model(activity_log, post_json, user, community) -> Post: if post.url: if is_image_url(post.url): post.type = POST_TYPE_IMAGE - if 'image' in post_json and 'url' in post_json['image']: - image = File(source_url=post_json['image']['url']) - else: - image = File(source_url=post.url) - if alt_text: - image.alt_text = alt_text + image = File(source_url=post.url) + if alt_text: + image.alt_text = alt_text db.session.add(image) post.image = image elif is_video_url(post.url): diff --git a/app/models.py b/app/models.py index 6b472e66..e3640cbd 100644 --- a/app/models.py +++ b/app/models.py @@ -1233,10 +1233,7 @@ class Post(db.Model): if post.url: if is_image_url(post.url): post.type = constants.POST_TYPE_IMAGE - if 'image' in request_json['object'] and 'url' in request_json['object']['image']: - image = File(source_url=request_json['object']['image']['url']) - else: - image = File(source_url=post.url) + image = File(source_url=post.url) if alt_text: image.alt_text = alt_text db.session.add(image)