From b9a88a7fa6ae37ce582eec42ef986d4a969f8c08 Mon Sep 17 00:00:00 2001 From: rimu <3310831+rimu@users.noreply.github.com> Date: Mon, 4 Mar 2024 10:56:17 +1300 Subject: [PATCH] save local copy of link posts where the link is to an image --- app/activitypub/util.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/activitypub/util.py b/app/activitypub/util.py index 2ff418e1..67be217a 100644 --- a/app/activitypub/util.py +++ b/app/activitypub/util.py @@ -1222,6 +1222,9 @@ def create_post(activity_log: ActivityPubLog, community: Community, request_json post.url = request_json['object']['attachment'][0]['href'] if is_image_url(post.url): post.type = POST_TYPE_IMAGE + image = File(source_url=request_json['object']['image']['url']) + db.session.add(image) + post.image = image else: post.type = POST_TYPE_LINK domain = domain_from_url(post.url) @@ -1247,7 +1250,7 @@ def create_post(activity_log: ActivityPubLog, community: Community, request_json if not domain.banned: domain.post_count += 1 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']) db.session.add(image) post.image = image