mirror of
https://codeberg.org/rimu/pyfedi
synced 2025-01-24 11:51:27 -08:00
Merge remote-tracking branch 'upstream/main'
This commit is contained in:
commit
fcde28e178
2 changed files with 9 additions and 6 deletions
|
@ -125,24 +125,24 @@ def post_to_activity(post: Post, community: Community):
|
||||||
],
|
],
|
||||||
"object": {
|
"object": {
|
||||||
"id": create_id,
|
"id": create_id,
|
||||||
"actor": f"https://{current_app.config['SERVER_NAME']}/u/{post.author.user_name}",
|
"actor": post.author.ap_public_url,
|
||||||
"to": [
|
"to": [
|
||||||
"https://www.w3.org/ns/activitystreams#Public"
|
"https://www.w3.org/ns/activitystreams#Public"
|
||||||
],
|
],
|
||||||
"object": {
|
"object": {
|
||||||
"type": "Page",
|
"type": "Page",
|
||||||
"id": f"https://{current_app.config['SERVER_NAME']}/post/{post.id}",
|
"id": post.ap_id,
|
||||||
"attributedTo": f"https://{current_app.config['SERVER_NAME']}/u/{post.author.user_name}",
|
"attributedTo": post.author.ap_public_url,
|
||||||
"to": [
|
"to": [
|
||||||
f"https://{current_app.config['SERVER_NAME']}/c/{community.name}",
|
f"https://{current_app.config['SERVER_NAME']}/c/{community.name}",
|
||||||
"https://www.w3.org/ns/activitystreams#Public"
|
"https://www.w3.org/ns/activitystreams#Public"
|
||||||
],
|
],
|
||||||
"name": post.title,
|
"name": post.title,
|
||||||
"cc": [],
|
"cc": [],
|
||||||
"content": post.body_html,
|
"content": post.body_html if post.body_html else '',
|
||||||
"mediaType": "text/html",
|
"mediaType": "text/html",
|
||||||
"source": {
|
"source": {
|
||||||
"content": post.body,
|
"content": post.body if post.body else '',
|
||||||
"mediaType": "text/markdown"
|
"mediaType": "text/markdown"
|
||||||
},
|
},
|
||||||
"attachment": [],
|
"attachment": [],
|
||||||
|
@ -704,6 +704,9 @@ def make_image_sizes_async(file_id, thumbnail_width, medium_width, directory):
|
||||||
content_type_parts = content_type.split('/')
|
content_type_parts = content_type.split('/')
|
||||||
if content_type_parts:
|
if content_type_parts:
|
||||||
file_ext = '.' + content_type_parts[-1]
|
file_ext = '.' + content_type_parts[-1]
|
||||||
|
else:
|
||||||
|
if '?' in file_ext:
|
||||||
|
file_ext = file_ext.split('?')[0]
|
||||||
|
|
||||||
new_filename = gibberish(15)
|
new_filename = gibberish(15)
|
||||||
|
|
||||||
|
|
|
@ -211,7 +211,7 @@ def save_post(form, post: Post):
|
||||||
filename = opengraph.get('og:image') or opengraph.get('og:image:url')
|
filename = opengraph.get('og:image') or opengraph.get('og:image:url')
|
||||||
filename_for_extension = filename.split('?')[0] if '?' in filename else filename
|
filename_for_extension = filename.split('?')[0] if '?' in filename else filename
|
||||||
unused, file_extension = os.path.splitext(filename_for_extension)
|
unused, file_extension = os.path.splitext(filename_for_extension)
|
||||||
if file_extension.lower() in allowed_extensions:
|
if file_extension.lower() in allowed_extensions and not filename.startswith('/'):
|
||||||
file = url_to_thumbnail_file(filename)
|
file = url_to_thumbnail_file(filename)
|
||||||
if file:
|
if file:
|
||||||
file.alt_text = opengraph.get('og:title')
|
file.alt_text = opengraph.get('og:title')
|
||||||
|
|
Loading…
Add table
Reference in a new issue