image upload bugfixes #218

This commit is contained in:
rimu 2024-06-25 21:11:57 +08:00
parent a19374a652
commit be41133dd9
3 changed files with 4 additions and 3 deletions

View file

@ -1033,7 +1033,7 @@ def federate_post_to_user_followers(post):
note['content'] = '<p><a href=' + post.url + '>' + post.title + '</a></p>'
elif post.type == POST_TYPE_IMAGE:
note['content'] = '<p>' + post.title + '</p>'
if post.image.id and post.image.source_url:
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:

View file

@ -354,8 +354,9 @@ def save_post(form, post: Post, type: str):
width=img_width, height=img_height, thumbnail_width=thumbnail_width,
thumbnail_height=thumbnail_height, thumbnail_path=final_place_thumbnail,
source_url=final_place.replace('app/static/', f"https://{current_app.config['SERVER_NAME']}/static/"))
post.image = file
db.session.add(file)
db.session.commit()
post.image_id = file.id
elif type == 'video':
form.video_url.data = form.video_url.data.strip()
post.title = form.video_title.data

View file

@ -1446,7 +1446,7 @@ def federate_post_edit_to_user_followers(post):
note['content'] = '<p><a href=' + post.url + '>' + post.title + '</a></p>'
elif post.type == POST_TYPE_IMAGE:
note['content'] = '<p>' + post.title + '</p>'
if post.image.id and post.image.source_url:
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: