From 2729539d8c6b4c574e1c29aae4376613fe88495e Mon Sep 17 00:00:00 2001 From: rimu <3310831+rimu@users.noreply.github.com> Date: Tue, 9 Apr 2024 19:27:42 +1200 Subject: [PATCH] only attach image to post if post was successfully created --- app/activitypub/util.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/activitypub/util.py b/app/activitypub/util.py index 7f1e7c47..f6563c1e 100644 --- a/app/activitypub/util.py +++ b/app/activitypub/util.py @@ -706,12 +706,12 @@ def post_json_to_model(activity_log, post_json, user, community) -> Post: if not domain.banned: domain.post_count += 1 post.domain = domain - if 'image' in post_json and post.image is None: - image = File(source_url=post_json['image']['url']) - db.session.add(image) - post.image = image if post is not None: + if 'image' in post_json and post.image is None: + image = File(source_url=post_json['image']['url']) + db.session.add(image) + post.image = image db.session.add(post) community.post_count += 1 activity_log.result = 'success'