mirror of
https://codeberg.org/rimu/pyfedi
synced 2025-01-24 03:43:42 -08:00
save local copy of link posts where the link is to an image
This commit is contained in:
parent
4afcf56a7b
commit
b9a88a7fa6
1 changed files with 4 additions and 1 deletions
|
@ -1222,6 +1222,9 @@ def create_post(activity_log: ActivityPubLog, community: Community, request_json
|
||||||
post.url = request_json['object']['attachment'][0]['href']
|
post.url = request_json['object']['attachment'][0]['href']
|
||||||
if is_image_url(post.url):
|
if is_image_url(post.url):
|
||||||
post.type = POST_TYPE_IMAGE
|
post.type = POST_TYPE_IMAGE
|
||||||
|
image = File(source_url=request_json['object']['image']['url'])
|
||||||
|
db.session.add(image)
|
||||||
|
post.image = image
|
||||||
else:
|
else:
|
||||||
post.type = POST_TYPE_LINK
|
post.type = POST_TYPE_LINK
|
||||||
domain = domain_from_url(post.url)
|
domain = domain_from_url(post.url)
|
||||||
|
@ -1247,7 +1250,7 @@ def create_post(activity_log: ActivityPubLog, community: Community, request_json
|
||||||
if not domain.banned:
|
if not domain.banned:
|
||||||
domain.post_count += 1
|
domain.post_count += 1
|
||||||
post.domain = domain
|
post.domain = domain
|
||||||
if 'image' in request_json['object']:
|
if 'image' in request_json['object'] and post.image is None:
|
||||||
image = File(source_url=request_json['object']['image']['url'])
|
image = File(source_url=request_json['object']['image']['url'])
|
||||||
db.session.add(image)
|
db.session.add(image)
|
||||||
post.image = image
|
post.image = image
|
||||||
|
|
Loading…
Add table
Reference in a new issue