mirror of
https://codeberg.org/rimu/pyfedi
synced 2025-02-03 00:31:25 -08:00
Bugfix for posts with empty attachments
This commit is contained in:
parent
73f0ff35f4
commit
ec91e6c7d2
2 changed files with 8 additions and 4 deletions
|
@ -1833,8 +1833,10 @@ def update_post_from_activity(post: Post, request_json: dict):
|
||||||
# Links
|
# Links
|
||||||
old_url = post.url
|
old_url = post.url
|
||||||
new_url = None
|
new_url = None
|
||||||
if 'attachment' in request_json['object'] and isinstance(request_json['object']['attachment'], list) and \
|
if ('attachment' in request_json['object'] and
|
||||||
'type' in request_json['object']['attachment'][0]:
|
isinstance(request_json['object']['attachment'], list) and
|
||||||
|
len(request_json['object']['attachment']) > 0 and
|
||||||
|
'type' in request_json['object']['attachment'][0]):
|
||||||
if request_json['object']['attachment'][0]['type'] == 'Link':
|
if request_json['object']['attachment'][0]['type'] == 'Link':
|
||||||
new_url = request_json['object']['attachment'][0]['href'] # Lemmy < 0.19.4
|
new_url = request_json['object']['attachment'][0]['href'] # Lemmy < 0.19.4
|
||||||
if request_json['object']['attachment'][0]['type'] == 'Document':
|
if request_json['object']['attachment'][0]['type'] == 'Document':
|
||||||
|
|
|
@ -1227,8 +1227,10 @@ class Post(db.Model):
|
||||||
if blocked_phrase in post.body:
|
if blocked_phrase in post.body:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
if 'attachment' in request_json['object'] and isinstance(request_json['object']['attachment'], list) and \
|
if ('attachment' in request_json['object'] and
|
||||||
'type' in request_json['object']['attachment'][0]:
|
isinstance(request_json['object']['attachment'], list) and
|
||||||
|
len(request_json['object']['attachment']) > 0 and
|
||||||
|
'type' in request_json['object']['attachment'][0]):
|
||||||
alt_text = None
|
alt_text = None
|
||||||
if request_json['object']['attachment'][0]['type'] == 'Link':
|
if request_json['object']['attachment'][0]['type'] == 'Link':
|
||||||
post.url = request_json['object']['attachment'][0]['href'] # Lemmy < 0.19.4
|
post.url = request_json['object']['attachment'][0]['href'] # Lemmy < 0.19.4
|
||||||
|
|
Loading…
Add table
Reference in a new issue