Prefer image in attachment for image posts #350

This commit is contained in:
freamon 2024-11-17 22:14:39 +00:00
parent 594b858bd4
commit 5e422131ad
2 changed files with 4 additions and 10 deletions

View file

@ -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):

View file

@ -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)